@@ -46,6 +46,103 @@ static void VerifyWrapper<T>(
4646 wrapper . GetInput < T > ( ) . Should ( ) . Be ( input ) ;
4747 }
4848
49+ [ Fact ]
50+ public void ContinueAsNew_WithoutVersion_CallsInnerContextWithoutVersion ( )
51+ {
52+ // Arrange
53+ TrackingOrchestrationContext innerContext = new ( ) ;
54+ OrchestrationInvocationContext invocationContext = new ( "Test" , new ( ) , NullLoggerFactory . Instance , null ) ;
55+ TaskOrchestrationContextWrapper wrapper = new ( innerContext , invocationContext , "input" ) ;
56+
57+ // Act
58+ wrapper . ContinueAsNew ( "new-input" , preserveUnprocessedEvents : false ) ;
59+
60+ // Assert
61+ innerContext . LastContinueAsNewInput . Should ( ) . Be ( "new-input" ) ;
62+ innerContext . LastContinueAsNewVersion . Should ( ) . BeNull ( ) ;
63+ }
64+
65+ [ Fact ]
66+ public void ContinueAsNew_WithVersion_CallsInnerContextWithVersion ( )
67+ {
68+ // Arrange
69+ TrackingOrchestrationContext innerContext = new ( ) ;
70+ OrchestrationInvocationContext invocationContext = new ( "Test" , new ( ) , NullLoggerFactory . Instance , null ) ;
71+ TaskOrchestrationContextWrapper wrapper = new ( innerContext , invocationContext , "input" ) ;
72+
73+ // Act
74+ wrapper . ContinueAsNew ( new ContinueAsNewOptions { NewVersion = "v2" } , "new-input" , preserveUnprocessedEvents : false ) ;
75+
76+ // Assert
77+ innerContext . LastContinueAsNewInput . Should ( ) . Be ( "new-input" ) ;
78+ innerContext . LastContinueAsNewVersion . Should ( ) . Be ( "v2" ) ;
79+ }
80+
81+ [ Fact ]
82+ public void ContinueAsNew_WithNullOptions_CallsInnerContextWithoutVersion ( )
83+ {
84+ // Arrange
85+ TrackingOrchestrationContext innerContext = new ( ) ;
86+ OrchestrationInvocationContext invocationContext = new ( "Test" , new ( ) , NullLoggerFactory . Instance , null ) ;
87+ TaskOrchestrationContextWrapper wrapper = new ( innerContext , invocationContext , "input" ) ;
88+
89+ // Act
90+ wrapper . ContinueAsNew ( options : null , newInput : "new-input" , preserveUnprocessedEvents : false ) ;
91+
92+ // Assert
93+ innerContext . LastContinueAsNewInput . Should ( ) . Be ( "new-input" ) ;
94+ innerContext . LastContinueAsNewVersion . Should ( ) . BeNull ( ) ;
95+ }
96+
97+ class TrackingOrchestrationContext : OrchestrationContext
98+ {
99+ public TrackingOrchestrationContext ( )
100+ {
101+ this . OrchestrationInstance = new ( )
102+ {
103+ InstanceId = Guid . NewGuid ( ) . ToString ( ) ,
104+ ExecutionId = Guid . NewGuid ( ) . ToString ( ) ,
105+ } ;
106+ }
107+
108+ public object ? LastContinueAsNewInput { get ; private set ; }
109+
110+ public string ? LastContinueAsNewVersion { get ; private set ; }
111+
112+ public override void ContinueAsNew ( object input )
113+ {
114+ this . LastContinueAsNewInput = input ;
115+ this . LastContinueAsNewVersion = null ;
116+ }
117+
118+ public override void ContinueAsNew ( string newVersion , object input )
119+ {
120+ this . LastContinueAsNewInput = input ;
121+ this . LastContinueAsNewVersion = newVersion ;
122+ }
123+
124+ public override Task < T > CreateSubOrchestrationInstance < T > ( string name , string version , object input )
125+ => throw new NotImplementedException ( ) ;
126+
127+ public override Task < T > CreateSubOrchestrationInstance < T > ( string name , string version , string instanceId , object input )
128+ => throw new NotImplementedException ( ) ;
129+
130+ public override Task < T > CreateSubOrchestrationInstance < T > ( string name , string version , string instanceId , object input , IDictionary < string , string > tags )
131+ => throw new NotImplementedException ( ) ;
132+
133+ public override Task < T > CreateTimer < T > ( DateTime fireAt , T state )
134+ => throw new NotImplementedException ( ) ;
135+
136+ public override Task < T > CreateTimer < T > ( DateTime fireAt , T state , CancellationToken cancelToken )
137+ => throw new NotImplementedException ( ) ;
138+
139+ public override Task < TResult > ScheduleTask < TResult > ( string name , string version , params object [ ] parameters )
140+ => throw new NotImplementedException ( ) ;
141+
142+ public override void SendEvent ( OrchestrationInstance orchestrationInstance , string eventName , object eventData )
143+ => throw new NotImplementedException ( ) ;
144+ }
145+
49146 class TestOrchestrationContext : OrchestrationContext
50147 {
51148 public TestOrchestrationContext ( )
0 commit comments