File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
test/WorkflowCore.IntegrationTests/Scenarios Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -65,23 +65,27 @@ public async Task StopAsync_should_wait_for_running_steps_to_complete()
65
65
var workflowId = await Host . StartWorkflow < Object > ( "StopAsyncWorkflow" , null ) ;
66
66
67
67
// Wait for the step to start executing
68
- await Task . Delay ( 500 ) ;
69
- var stepStartedTime = DateTime . Now ;
68
+ var waitCount = 0 ;
69
+ while ( StopAsyncWorkflow . StepStartTime == null && waitCount < 50 )
70
+ {
71
+ await Task . Delay ( 100 ) ;
72
+ waitCount ++ ;
73
+ }
74
+
75
+ StopAsyncWorkflow . StepStartTime . Should ( ) . NotBeNull ( "the step should have started before stopping" ) ;
76
+ StopAsyncWorkflow . StepEndTime . Should ( ) . BeNull ( "the step should still be running" ) ;
70
77
71
78
// Act - Call StopAsync which should wait for the step to complete
72
79
var stopwatch = Stopwatch . StartNew ( ) ;
73
80
await Host . StopAsync ( default ) ;
74
81
stopwatch . Stop ( ) ;
75
82
76
83
// Assert
77
- // The step should have started
78
- StopAsyncWorkflow . StepStartTime . Should ( ) . NotBeNull ( "the step should have started" ) ;
79
-
80
84
// The step should have completed
81
85
StopAsyncWorkflow . StepEndTime . Should ( ) . NotBeNull ( "the step should have completed before StopAsync returned" ) ;
82
86
83
- // StopAsync should have taken at least 4 seconds (5 seconds delay minus the 500ms we waited )
84
- stopwatch . ElapsedMilliseconds . Should ( ) . BeGreaterThan ( 4000 ,
87
+ // StopAsync should have taken at least 3 seconds (the remaining delay time )
88
+ stopwatch . ElapsedMilliseconds . Should ( ) . BeGreaterOrEqualTo ( 3000 ,
85
89
"StopAsync should wait for the running step to complete" ) ;
86
90
}
87
91
You can’t perform that action at this time.
0 commit comments