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()
6565 var workflowId = await Host . StartWorkflow < Object > ( "StopAsyncWorkflow" , null ) ;
6666
6767 // 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" ) ;
7077
7178 // Act - Call StopAsync which should wait for the step to complete
7279 var stopwatch = Stopwatch . StartNew ( ) ;
7380 await Host . StopAsync ( default ) ;
7481 stopwatch . Stop ( ) ;
7582
7683 // Assert
77- // The step should have started
78- StopAsyncWorkflow . StepStartTime . Should ( ) . NotBeNull ( "the step should have started" ) ;
79-
8084 // The step should have completed
8185 StopAsyncWorkflow . StepEndTime . Should ( ) . NotBeNull ( "the step should have completed before StopAsync returned" ) ;
8286
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 ,
8589 "StopAsync should wait for the running step to complete" ) ;
8690 }
8791
You can’t perform that action at this time.
0 commit comments