1- using WorkflowCore . Interface ;
2- using WorkflowCore . Models ;
3- using Xunit ;
1+ using System . Threading ;
2+ using System . Threading . Tasks ;
43using FluentAssertions ;
5- using WorkflowCore . Testing ;
4+ using WorkflowCore . Interface ;
5+ using WorkflowCore . Models ;
66using WorkflowCore . Models . LifeCycleEvents ;
7- using System . Threading . Tasks ;
8- using System . Threading ;
9- using Moq ;
7+ using WorkflowCore . Testing ;
8+ using Xunit ;
109
1110namespace WorkflowCore . IntegrationTests . Scenarios
1211{
@@ -18,33 +17,29 @@ public class StopWorkflow : IWorkflow
1817 public int Version => 1 ;
1918 public void Build ( IWorkflowBuilder < object > builder )
2019 {
21- builder . StartWith ( context => ExecutionResult . Next ( ) ) ;
20+ builder . StartWith ( context => ExecutionResult . Next ( ) ) ;
2221 }
2322 }
2423
25- public StopScenario ( )
26- {
27- Setup ( ) ;
28- }
24+ public StopScenario ( ) => Setup ( ) ;
2925
3026 [ Fact ]
3127 public async Task Scenario ( )
3228 {
3329 var tcs = new TaskCompletionSource < object > ( ) ;
34- Host . OnLifeCycleEvent += ( evt ) => OnLifeCycleEvent ( evt , tcs ) ;
35- var workflowId = StartWorkflow ( null ) ;
30+ Host . OnLifeCycleEvent += async ( evt ) =>
31+ {
32+ if ( evt is WorkflowCompleted )
33+ {
34+ await Host . StopAsync ( CancellationToken . None ) ;
35+ tcs . SetResult ( default ) ;
36+ }
37+ } ;
3638
39+ var workflowId = StartWorkflow ( default ) ;
3740 await tcs . Task ;
38- GetStatus ( workflowId ) . Should ( ) . Be ( WorkflowStatus . Complete ) ;
39- }
4041
41- private async void OnLifeCycleEvent ( LifeCycleEvent evt , TaskCompletionSource < object > tcs )
42- {
43- if ( evt is WorkflowCompleted )
44- {
45- await Host . StopAsync ( CancellationToken . None ) ;
46- tcs . SetResult ( new ( ) ) ;
47- }
42+ GetStatus ( workflowId ) . Should ( ) . Be ( WorkflowStatus . Complete ) ;
4843 }
4944
5045 protected override void Dispose ( bool disposing ) { }
0 commit comments