public void DoWhileWithWorkFlowInvoker() { Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestAssign <int> increment = new TestAssign <int>("Increment Counter") { ToVariable = counter, ValueExpression = ((env) => (((int)counter.Get(env))) + 1) }; TestDoWhile doWhile = new TestDoWhile("dowhile") { ConditionExpression = (env) => ((int)counter.Get(env)) < 2, Body = increment, HintIterationCount = 2, Variables = { counter } }; TestWriteLine writeLine = new TestWriteLine("write hello") { Message = "Its a small world after all" }; TestRuntime.RunAndValidateUsingWorkflowInvoker(doWhile, null, null, null); }
public void ParallelForEachWithWorkflowInvoker() { TestSequence innerSequence = new TestSequence("innerSeq"); DelegateInArgument <string> i = new DelegateInArgument <string>() { Name = "i" }; string[] strArray = new string[] { "var1", "var2", "var3" }; TestParallelForEach <string> foreachAct = new TestParallelForEach <string>("foreach") { HintValues = strArray, ValuesExpression = (context => new string[] { "var1", "var2", "var3" }), CurrentVariable = i, HintIterationCount = 3 }; TestWriteLine writeLine = new TestWriteLine("write hello") { MessageExpression = ((env) => string.Format("WriteLine Argument: {0}", i.Get(env))) }; for (int counter = strArray.Length - 1; counter > -1; counter--) { writeLine.HintMessageList.Add("WriteLine Argument: " + strArray[counter]); } foreachAct.Body = innerSequence; innerSequence.Activities.Add(writeLine); TestRuntime.RunAndValidateUsingWorkflowInvoker(foreachAct, null, null, null); }
public void TryCatchWithWorkflowInvoker() { TestTryCatch tcf = new TestTryCatch { // try Try = new TestThrow <ArgumentException>() { ExpectedOutcome = Outcome.CaughtException() } }; // catch TestCatch <ArgumentException> tc = new TestCatch <ArgumentException> { Body = new TestWriteLine("Hello world!", "Hello world!") }; tcf.Catches.Add(tc); // finally tcf.Finally = new TestWriteLine("Finally", "Finally"); // Run test TestRuntime.RunAndValidateUsingWorkflowInvoker(tcf, null, null, null); }
public void InvokeWithWorkflowInvoker() { TestRuntime.RunAndValidateUsingWorkflowInvoker(new TestNew <ParameterLessConstructorType>(), null, new Dictionary <string, object> { { "Result", new ParameterLessConstructorType() } }, null); }
public void InvokeWithWorkflowInvoker() { TestRuntime.RunAndValidateUsingWorkflowInvoker(new TestOrElse(false, true), null, new Dictionary <string, object> { { "Result", true } }, null); }
public void SequenceWithWorkFlowInvoker() { Variable <string> note = VariableHelper.CreateInitialized <string>("note", "It's funny"); TestSequence sequence = new TestSequence("Seq"); sequence.Activities.Add(new TestWriteLine("w1", note, "It's funny")); sequence.Variables.Add(note); TestRuntime.RunAndValidateUsingWorkflowInvoker(sequence, null, null, null); }
public void WhileWithWorkFlowInvoker() { TestWhile whileAct = new TestWhile(); whileAct.Body = new TestWriteLine("w1", "This should not be written"); whileAct.Condition = false; whileAct.HintIterationCount = -1; TestRuntime.RunAndValidateUsingWorkflowInvoker(whileAct, null, null, null); }
public void InvokeWithWorkflowInvoker() { TestRuntime.RunAndValidateUsingWorkflowInvoker(new TestGreaterThan <int, int, bool>(), new Dictionary <string, object> { { "Left", 5 }, { "Right", 5 } }, new Dictionary <string, object> { { "Result", false } }, null); }
public void InvokeWithWorkflowInvoker() { TestRuntime.RunAndValidateUsingWorkflowInvoker(new TestNotEqual <Complex, Complex, bool>(), new Dictionary <string, object> { { "Left", new Complex(1, 2) }, { "Right", new Complex(1, 2) } }, new Dictionary <string, object> { { "Result", false } }, null); }
public void InvokeWithWorkflowInvoker() { TestRuntime.RunAndValidateUsingWorkflowInvoker(new TestAs <Base, Derived>(), new Dictionary <string, object> { { "Operand", new Derived() } }, new Dictionary <string, object> { { "Result", new Derived() } }, null); }
public void InvokeWithWorkflowInvoker() { TestRuntime.RunAndValidateUsingWorkflowInvoker(new TestNot <bool, bool>(), new Dictionary <string, object> { { "Operand", true } }, new Dictionary <string, object> { { "Result", false } }, null); }
public void InvokeWithWorkflowInvoker() { TestRuntime.RunAndValidateUsingWorkflowInvoker(new TestOr <int, int, int>(), new Dictionary <string, object> { { "Left", 1 }, { "Right", 0 } }, new Dictionary <string, object> { { "Result", 1 } }, null); }
public void AssignWithWorkflowInvoker() { Type hello = typeof(Exception); TestAssign <Type> assign = new TestAssign <Type>(); Dictionary <string, object> inputs = new Dictionary <string, object>(); inputs.Add("Value", hello); Dictionary <string, object> outputs = new Dictionary <string, object>(); outputs.Add("To", hello); TestRuntime.RunAndValidateUsingWorkflowInvoker(assign, inputs, outputs, null); }
public void IfConditionSetToTrue() { // Test case description: // Set condition to null TestIf ifAct = new TestIf("if act", HintThenOrElse.Then) { Condition = true, ThenActivity = new TestWriteLine("Write Hello", "It's a small world after all"), }; TestRuntime.RunAndValidateUsingWorkflowInvoker(ifAct, null, null, null); }
public void InvokeWithWorkflowInvoker() { TestAnd <bool, bool, bool> and = new TestAnd <bool, bool, bool>(); TestRuntime.RunAndValidateUsingWorkflowInvoker(and, new Dictionary <string, object> { { "Left", true }, { "Right", false } }, new Dictionary <string, object> { { "Result", false } }, new List <object>()); }
public void InvokeWithWorkflowInvoker() { TestAndAlso andAlso = new TestAndAlso { Left = true, Right = false }; TestRuntime.RunAndValidateUsingWorkflowInvoker(andAlso, null, new Dictionary <string, object> { { "Result", false } }, null); }
public void InvokeWithWorkflowInvoker() { TestRuntime.RunAndValidateUsingWorkflowInvoker(new TestArrayItemValue <int>(), new Dictionary <string, object> { { "Array", new int[3] { 1, 2, 3 } }, { "Index", 1 } }, new Dictionary <string, object> { { "Result", 2 } }, null); }
public void IfWithWorkflowInvoker() { TestIf ifAct = new TestIf("MyIf", HintThenOrElse.Then) { ThenActivity = new TestWriteLine("w", "I'm Funny"), ElseActivity = new TestWriteLine("w", "I'm not Funny!") }; Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("Condition", true); TestRuntime.RunAndValidateUsingWorkflowInvoker(ifAct, args, null, null); }
public void InvokeWithWorkflowInvoker() { TestRuntime.RunAndValidateUsingWorkflowInvoker(new TestFieldValue <PublicType, string>() { FieldName = "publicField" }, new Dictionary <string, object> { { "Operand", new PublicType { publicField = "10" } } }, new Dictionary <string, object> { { "Result", "10" } }, null); }
public void InvokeWithWorkflowInvoker() { TestRuntime.RunAndValidateUsingWorkflowInvoker(new TestPropertyValue <PublicType, int> { PropertyName = "PublicProperty" }, new Dictionary <string, object> { { "Operand", new PublicType() { PublicProperty = 22 } } }, new Dictionary <string, object> { { "Result", 22 } }, null); }
public void WriteLineWithWorkflowInvoker() { string stringToWrite = "Hello World"; using (StreamWriter streamWriter = ConsoleSetOut()) { { TestProductWriteline writeline = new TestProductWriteline("Write Hello"); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("Text", stringToWrite); TestRuntime.RunAndValidateUsingWorkflowInvoker(writeline, dic, null, null); } } VerifyTextOfWriteLine(_tempFilePath, stringToWrite); }
public void WriteInTextFileWithStreamWriter() { string stringToWrite = "Writing text to a file with StreamWriter object"; using (StreamWriter streamWriter = new StreamWriter(new FileStream(_tempFilePath, FileMode.Create, FileAccess.Write))) { Dictionary <string, object> inputs = new Dictionary <string, object>(); inputs.Add("Text", stringToWrite); inputs.Add("TextWriter", streamWriter); TestProductWriteline writeline = new TestProductWriteline("Write with StreamWriter"); TestRuntime.RunAndValidateUsingWorkflowInvoker(writeline, inputs, null, null); } VerifyTextOfWriteLine(_tempFilePath, stringToWrite); }
public void ParallelWithWorkFlowInvoker() { TestWriteLine writeLine1 = new TestWriteLine(); writeLine1.Message = "writeLine1"; writeLine1.DisplayName = "writeLine1"; TestWriteLine writeLine2 = new TestWriteLine(); writeLine2.Message = "writeLine2"; writeLine2.DisplayName = "writeLine2"; TestParallel parallelActivity = new TestParallel("Parallel Activity"); parallelActivity.Branches.Add(writeLine1); parallelActivity.Branches.Add(writeLine2); TestRuntime.RunAndValidateUsingWorkflowInvoker(parallelActivity, null, null, null); }
public void TerminateInstanceWithInvokerUsingTerminateActivity() { s_exceptionType = typeof(TestCaseFailedException); s_exceptionMsg = "Name is Not Found"; s_terminationReason = "Name is not here"; TestSequence seq = new TestSequence("TerminateSeq") { Activities = { new TestTerminateWorkflow("Terminating") { ExceptionExpression = ((env) => new TestCaseFailedException("Name is Not Found")), Reason = s_terminationReason } }, }; try { TestRuntime.RunAndValidateUsingWorkflowInvoker(seq, null, null, null); throw new TestCaseFailedException("An exception should have been thrown"); } catch (WorkflowTerminatedException exception) { if (exception.InnerException.GetType() != s_exceptionType) { throw new TestCaseFailedException("Exception is Incorrect"); } if (!exception.InnerException.Message.Equals(s_exceptionMsg)) { throw new TestCaseFailedException("Exception Message is Incorrect"); } if (!exception.Message.Equals(s_terminationReason)) { throw new TestCaseFailedException("Reason Message is Incorrect"); } } }
public void SwitchWithWorkflowInvoker() { TestSwitch <int> switchAct = new TestSwitch <int>(); switchAct.AddCase(12, new TestProductWriteline { Text = "in case 12" }); switchAct.AddCase(23, new TestProductWriteline { Text = "in case 23" }); switchAct.AddCase(123, new TestProductWriteline { Text = "in case 123" }); switchAct.AddCase(234, new TestProductWriteline { Text = "in case 234" }); switchAct.Hints.Add(2); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("Expression", 123); TestRuntime.RunAndValidateUsingWorkflowInvoker(switchAct, dic, null, null); }