@@ -223,6 +223,54 @@ public void should_map_outputs()
223
223
data . Value1 . Should ( ) . Be ( 7 ) ;
224
224
}
225
225
226
+ [ Fact ( DisplayName = "Should map dynamic outputs" ) ]
227
+ public void should_map_outputs_dynamic ( )
228
+ {
229
+ //arrange
230
+ Expression < Func < IStepWithProperties , int > > p1 = x => x . Property1 ;
231
+ Expression < Func < DynamicDataClass , IStepExecutionContext , int > > v1 = ( x , context ) => x [ "Value1" ] ;
232
+
233
+ var step1Body = A . Fake < IStepWithProperties > ( ) ;
234
+ A . CallTo ( ( ) => step1Body . Property1 ) . Returns ( 7 ) ;
235
+ A . CallTo ( ( ) => step1Body . RunAsync ( A < IStepExecutionContext > . Ignored ) ) . Returns ( ExecutionResult . Next ( ) ) ;
236
+ WorkflowStep step1 = BuildFakeStep ( step1Body , new List < DataMapping > ( ) , new List < DataMapping > ( )
237
+ {
238
+ new DataMapping ( )
239
+ {
240
+ Source = p1 ,
241
+ Target = v1
242
+ }
243
+ }
244
+ ) ;
245
+
246
+ Given1StepWorkflow ( step1 , "Workflow" , 1 ) ;
247
+
248
+ var data = new DynamicDataClass ( )
249
+ {
250
+ [ "Value1" ] = 5
251
+ } ;
252
+
253
+ var instance = new WorkflowInstance
254
+ {
255
+ WorkflowDefinitionId = "Workflow" ,
256
+ Version = 1 ,
257
+ Status = WorkflowStatus . Runnable ,
258
+ NextExecution = 0 ,
259
+ Id = "001" ,
260
+ Data = data ,
261
+ ExecutionPointers = new List < ExecutionPointer > ( )
262
+ {
263
+ new ExecutionPointer ( ) { Active = true , StepId = 0 }
264
+ }
265
+ } ;
266
+
267
+ //act
268
+ Subject . Execute ( instance ) ;
269
+
270
+ //assert
271
+ data [ "Value1" ] . Should ( ) . Be ( 7 ) ;
272
+ }
273
+
226
274
[ Fact ( DisplayName = "Should handle step exception" ) ]
227
275
public void should_handle_step_exception ( )
228
276
{
@@ -333,5 +381,16 @@ public class DataClass
333
381
public int Value2 { get ; set ; }
334
382
public int Value3 { get ; set ; }
335
383
}
384
+
385
+ public class DynamicDataClass
386
+ {
387
+ public Dictionary < string , int > Storage { get ; set ; } = new Dictionary < string , int > ( ) ;
388
+
389
+ public int this [ string propertyName ]
390
+ {
391
+ get => Storage [ propertyName ] ;
392
+ set => Storage [ propertyName ] = value ;
393
+ }
394
+ }
336
395
}
337
396
}
0 commit comments