11using Cleipnir . Flows . AspNet ;
22using Cleipnir . ResilientFunctions . Domain ;
33using Cleipnir . ResilientFunctions . Domain . Exceptions ;
4- using Cleipnir . ResilientFunctions . Reactive . Extensions ;
54using Cleipnir . ResilientFunctions . Storage ;
65using Microsoft . Extensions . DependencyInjection ;
76using Shouldly ;
@@ -18,7 +17,10 @@ public async Task SimpleFlowCompletesSuccessfully()
1817
1918 serviceCollection . AddFlows ( c => c
2019 . UseInMemoryStore ( )
21- . WithOptions ( new Options ( messagesDefaultMaxWaitForCompletion : TimeSpan . MaxValue ) )
20+ . WithOptions ( new Options (
21+ messagesDefaultMaxWaitForCompletion : TimeSpan . FromDays ( 1 ) ,
22+ watchdogCheckFrequency : TimeSpan . FromMilliseconds ( 100 )
23+ ) )
2224 . RegisterFlow < OptionsTestWithOverriddenOptionsFlow , OptionsTestWithOverriddenOptionsFlows > (
2325 flowsFactory : sp => new OptionsTestWithOverriddenOptionsFlows (
2426 sp . GetRequiredService < FlowsContainer > ( ) ,
@@ -34,19 +36,20 @@ public async Task SimpleFlowCompletesSuccessfully()
3436 await Should . ThrowAsync < InvocationSuspendedException > (
3537 ( ) => flowsWithOverridenOptions . Run ( "Id" )
3638 ) ;
37-
39+
3840 var flowsWithDefaultProvidedOptions = sp . GetRequiredService < OptionsTestWithDefaultProvidedOptionsFlows > ( ) ;
3941 await flowsWithDefaultProvidedOptions . Schedule ( "Id" ) ;
4042
4143 await Task . Delay ( 100 ) ;
42-
44+
4345 var controlPanel = await flowsWithDefaultProvidedOptions . ControlPanel ( "Id" ) ;
4446 controlPanel . ShouldNotBeNull ( ) ;
45- controlPanel . Status . ShouldBe ( Status . Executing ) ;
47+ // Flow may be Executing (waiting for message) or Suspended depending on timing
48+ controlPanel . Status . ShouldBeOneOf ( Status . Executing , Status . Suspended ) ;
4649
47- await controlPanel . Messages . Append ( "Hello" ) ;
50+ await controlPanel . Messages . Append ( new StringWrapper ( "Hello" ) ) ;
4851
49- await controlPanel . WaitForCompletion ( ) ;
52+ await controlPanel . WaitForCompletion ( allowPostponeAndSuspended : true ) ;
5053 }
5154
5255
@@ -60,7 +63,10 @@ public async Task FlowNameCanBeSpecifiedFromTheOutside()
6063
6164 serviceCollection . AddFlows ( c => c
6265 . UseInMemoryStore ( store )
63- . WithOptions ( new Options ( messagesDefaultMaxWaitForCompletion : TimeSpan . MaxValue ) )
66+ . WithOptions ( new Options (
67+ messagesDefaultMaxWaitForCompletion : TimeSpan . FromDays ( 1 ) ,
68+ watchdogCheckFrequency : TimeSpan . FromMilliseconds ( 100 )
69+ ) )
6470 . RegisterFlow < SimpleFlow , SimpleFlows > (
6571 flowsFactory : sp => new SimpleFlows (
6672 sp . GetRequiredService < FlowsContainer > ( ) ,
@@ -72,7 +78,7 @@ public async Task FlowNameCanBeSpecifiedFromTheOutside()
7278 var sp = serviceCollection . BuildServiceProvider ( ) ;
7379 var flows = sp . GetRequiredService < SimpleFlows > ( ) ;
7480 await flows . Run ( "Id" ) ;
75- var sf = await store . GetFunction ( new StoredId ( storedType , Instance : "Id" . ToStoredInstance ( ) ) ) ;
81+ var sf = await store . GetFunction ( StoredId . Create ( storedType , "Id" ) ) ;
7682 sf . ShouldNotBeNull ( ) ;
7783 sf . Status . ShouldBe ( Status . Succeeded ) ;
7884 }
@@ -83,19 +89,21 @@ public class OptionsTestWithOverriddenOptionsFlow : Flow
8389{
8490 public override async Task Run ( )
8591 {
86- await Messages . First ( ) ;
92+ await Message < StringWrapper > ( ) ;
8793 }
8894}
89-
95+
9096[ GenerateFlows ]
9197public class OptionsTestWithDefaultProvidedOptionsFlow : Flow
9298{
9399 public override async Task Run ( )
94100 {
95- await Messages . First ( ) ;
101+ await Message < StringWrapper > ( ) ;
96102 }
97103}
98104
105+ public record StringWrapper ( string Value ) ;
106+
99107[ GenerateFlows ]
100108public class SimpleFlow : Flow
101109{
0 commit comments