@@ -271,6 +271,58 @@ public void should_map_outputs_dynamic()
271
271
data [ "Value1" ] . Should ( ) . Be ( 7 ) ;
272
272
}
273
273
274
+ /// <summary>
275
+ /// This test verifies that storing an object that does not implement IConvertable, in a step variable of type object works.
276
+ /// The problem is that calling for example Convert.ChangeType(new DataClass(), typeof(object)) throws, even though the convertion should be trivial.
277
+ /// </summary>
278
+ [ Fact ( DisplayName = "Should map object outputs, without calling Convert.ChangeType" ) ]
279
+ public void should_map_outputs_object ( )
280
+ {
281
+ //arrange
282
+ Expression < Func < IStepWithProperties , object > > p1 = x => x . Property4 ;
283
+ Expression < Func < DataClass , IStepExecutionContext , object > > v1 = ( x , context ) => x . Value4 ;
284
+
285
+ var step1Body = A . Fake < IStepWithProperties > ( ) ;
286
+ A . CallTo ( ( ) => step1Body . Property4 ) . Returns ( new DataClass ( ) ) ;
287
+ A . CallTo ( ( ) => step1Body . RunAsync ( A < IStepExecutionContext > . Ignored ) ) . Returns ( ExecutionResult . Next ( ) ) ;
288
+ WorkflowStep step1 = BuildFakeStep ( step1Body , new List < DataMapping > ( ) , new List < DataMapping > ( )
289
+ {
290
+ new DataMapping ( )
291
+ {
292
+ Source = p1 ,
293
+ Target = v1
294
+ }
295
+ }
296
+ ) ;
297
+
298
+ Given1StepWorkflow ( step1 , "Workflow" , 1 ) ;
299
+
300
+ var data = new DataClass ( )
301
+ {
302
+ Value4 = 4
303
+ } ;
304
+
305
+ var instance = new WorkflowInstance
306
+ {
307
+ WorkflowDefinitionId = "Workflow" ,
308
+ Version = 1 ,
309
+ Status = WorkflowStatus . Runnable ,
310
+ NextExecution = 0 ,
311
+ Id = "001" ,
312
+ Data = data ,
313
+ ExecutionPointers = new List < ExecutionPointer > ( )
314
+ {
315
+ new ExecutionPointer ( ) { Active = true , StepId = 0 }
316
+ }
317
+ } ;
318
+
319
+ //act
320
+ Subject . Execute ( instance ) ;
321
+
322
+ //assert
323
+ data . Value4 . Should ( ) . BeOfType < DataClass > ( ) ;
324
+ }
325
+
274
326
[ Fact ( DisplayName = "Should handle step exception" ) ]
275
327
public void should_handle_step_exception ( )
276
328
{
@@ -372,14 +424,16 @@ public interface IStepWithProperties : IStepBody
372
424
{
373
425
int Property1 { get ; set ; }
374
426
int Property2 { get ; set ; }
375
- int Property3 { get ; set ; }
427
+ int Property3 { get ; set ; }
428
+ DataClass Property4 { get ; set ; }
376
429
}
377
430
378
431
public class DataClass
379
432
{
380
433
public int Value1 { get ; set ; }
381
434
public int Value2 { get ; set ; }
382
435
public int Value3 { get ; set ; }
436
+ public object Value4 { get ; set ; }
383
437
}
384
438
385
439
public class DynamicDataClass
0 commit comments