public void CastBaseTypeToDerivedType() { Variable <Base> operand = new Variable <Base>() { Name = "Operand" }; Variable <Derived> result = new Variable <Derived>() { Name = "Derived" }; Variable <string> output = new Variable <string>() { Name = "Output" }; TestInvokeMethod invokeMethod = new TestInvokeMethod { TargetObjectVariable = result, MethodName = "MethodInDerivedType" }; invokeMethod.SetResultVariable <string>(output); //Base b = new Derived(); //string result = ((Derived)b).MethodInDerivedType TestSequence seq = new TestSequence { Variables = { operand, result, output }, Activities = { new TestAssign <Base> { ToVariable = operand, ValueExpression = (context => new Derived()) }, new TestCast <Base, Derived> { OperandVariable = operand, Result = result }, invokeMethod, new TestWriteLine { MessageExpression = (e => output.Get(e)), HintMessage = "Ola" } } }; TestRuntime.RunAndValidateWorkflow(seq); }
public void UseBaseTypeAsDerivedType() { Variable <Derived> result = new Variable <Derived>() { Name = "Result" }; Variable <string> output = new Variable <string>() { Name = "Output" }; TestInvokeMethod invokeMethod = new TestInvokeMethod { TargetObjectVariable = result, MethodName = "MethodInDerivedType" }; invokeMethod.SetResultVariable <string>(output); //Base b = new Derived(); //string result = (b as Derived).MethodInDerivedType TestSequence seq = new TestSequence { Variables = { result, output }, Activities = { new TestAs <Base, Derived> { OperandExpression = context => new Derived(), Result = result }, invokeMethod, new TestWriteLine { MessageExpression = (e => output.Get(e)), HintMessage = "Ola" } } }; TestRuntime.RunAndValidateWorkflow(seq); }