public void RethrowExceptionFromInvokeMethodWithAllExceptionPropertiesSet() { TestInvokeMethod im = new TestInvokeMethod { TargetObject = new TestArgument <CustomClassForRethrow>(Direction.In, "TargetObject", (context => new CustomClassForRethrow())), MethodName = "M1", ExpectedOutcome = Outcome.CaughtException(typeof(TestCaseException)), }; TestTryCatch tc = new TestTryCatch(); TestCatch <TestCaseException> tcCatch = new TestCatch <TestCaseException> { Body = new TestRethrow { ExpectedOutcome = Outcome.UncaughtException(typeof(TestCaseException)) } }; tc.Try = im; tc.Catches.Add(tcCatch); using (TestWorkflowRuntime testWorkflowRuntime = TestRuntime.CreateTestWorkflowRuntime(tc)) { testWorkflowRuntime.ExecuteWorkflow(); Exception outEx; testWorkflowRuntime.WaitForAborted(out outEx); Dictionary <string, string> errorProperty = new Dictionary <string, string>(); errorProperty.Add("Message", "this should be caught"); ExceptionHelpers.ValidateException(outEx, typeof(TestCaseException), errorProperty); } }
public void SequenceWithMethodInvoke() { // Test case description: // Execute empty sequence activity - expected to pass TestSequence sequence = new TestSequence("Seq"); TestInvokeMethod methodInvokeAct = new TestInvokeMethod("methodinvoke", this.GetType().GetMethod("DummyMethod")); methodInvokeAct.TargetObject = new TestArgument <Sequence>(Direction.In, "TargetObject", (context => this)); sequence.Activities.Add(methodInvokeAct); TestRuntime.RunAndValidateWorkflow(sequence); }
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); }
public void BasicSequenceWithMultipleChildren() { // Test case description: // Execute sequence activity that has multiple different children in the Activities list and expect the // execution result be sequential as in the order they were added to the Activities list Stack <Guid> stackOfGuids = new Stack <Guid>(); stackOfGuids.Push(new Guid("11111111-1111-1111-1111-111111111111")); TestSequence sequence = new TestSequence("Sequence1"); TestSequence sequence2 = new TestSequence("InnerSequence1"); TestSequence sequence3 = new TestSequence("InnerSequence2"); TestSequence sequence4 = new TestSequence("InnerSequence3"); TestSequence sequence5 = new TestSequence("InnerSequence4"); Variable <Stack <Guid> > stack = VariableHelper.Create <Stack <Guid> >("keyed_collection"); TestInvokeMethod invokeact = new TestInvokeMethod("method invoke act", typeof(Sequence).GetMethod("CheckValue")); invokeact.TargetObject = new TestArgument <Sequence>(Direction.In, "TargetObject", (context => new Sequence())); invokeact.Arguments.Add(new TestArgument <Stack <Guid> >(Direction.In, "stack", stack)); TestSequence sequence6 = new TestSequence("seq5") { Variables = { stack }, Activities = { new TestWriteLine("hello writeline", "Hello from Mars"), new TestAssign <Stack <Guid> >("assign activity ") { ToVariable = stack, ValueExpression = context => stackOfGuids, }, new TestIf("ifact") { Condition = true, ThenActivity = invokeact } } }; TestSequence sequence7 = new TestSequence("seq6"); TestSequence sequence8 = new TestSequence("seq7"); TestSequence sequence9 = new TestSequence("seq8"); TestWriteLine writeLine2 = new TestWriteLine("Hello Two"); writeLine2.Message = string.Format("Hello world in {0} , {1} , {2}!", sequence.DisplayName, sequence3.DisplayName, sequence7.DisplayName); TestWriteLine writeLine3 = new TestWriteLine("Hello Three"); writeLine3.Message = string.Format("Hello world in {0} , {1} , {2}!", sequence.DisplayName, sequence4.DisplayName, sequence8.DisplayName); TestWriteLine writeLine4 = new TestWriteLine("Hello Four"); writeLine4.Message = string.Format("Hello world in {0} , {1} , {2}!", sequence.DisplayName, sequence5.DisplayName, sequence9.DisplayName); sequence7.Activities.Add(writeLine2); sequence8.Activities.Add(writeLine3); sequence9.Activities.Add(writeLine4); sequence2.Activities.Add(sequence6); sequence3.Activities.Add(sequence7); sequence4.Activities.Add(sequence8); sequence5.Activities.Add(sequence9); sequence.Activities.Add(sequence2); sequence.Activities.Add(sequence3); sequence.Activities.Add(sequence4); sequence.Activities.Add(sequence5); TestRuntime.RunAndValidateWorkflow(sequence); }