public void BasicDoWhileExecuteOnce() { TestSequence outerSequence = new TestSequence("sequence1"); TestSequence innerSequence = new TestSequence("innerseq"); TestAssign <int> increment = new TestAssign <int>("Increment Counter"); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestDoWhile doWhile = new TestDoWhile("dowhile") { ConditionExpression = (env) => ((int)counter.Get(env)) < 0, Body = innerSequence, HintIterationCount = 1, }; TestWriteLine writeLine = new TestWriteLine("write hello"); writeLine.Message = "Its a small world after all"; increment.ToVariable = counter; increment.ValueExpression = ((env) => (((int)counter.Get(env))) + 1); innerSequence.Activities.Add(writeLine); innerSequence.Activities.Add(increment); outerSequence.Variables.Add(counter); outerSequence.Activities.Add(doWhile); TestRuntime.RunAndValidateWorkflow(outerSequence); }
public void FlowDecisionAndFlowSwitchNotConnected() { TestFlowchart flowchart1 = new TestFlowchart("flowChart1"); TestWriteLine start1 = new TestWriteLine("Start", "Executing Start"); TestWriteLine w1 = new TestWriteLine("W1", "Executing W1"); TestWriteLine w2 = new TestWriteLine("W2", "Executing W2"); TestWriteLine w3 = new TestWriteLine("W3", "Executing W3"); TestWriteLine wDefault = new TestWriteLine("wDefault", "Executing wDefault"); Dictionary <string, TestActivity> cases = new Dictionary <string, TestActivity>(); cases.Add("One", w1); cases.Add("Two", w2); List <int> hints = new List <int>(); hints.Add(1); flowchart1.AddSwitchLink <string>(null, cases, hints, "Two", wDefault); TestWriteLine w2True = new TestWriteLine("True", "True will execute"); TestWriteLine w2False = new TestWriteLine("False", "False wont execute"); Variable <int> margin = VariableHelper.CreateInitialized <int>("Margin", 10); flowchart1.Variables.Add(margin); TestFlowConditional flowDecision = new TestFlowConditional(HintTrueFalse.True); flowDecision.ConditionExpression = (context => margin.Get(context) > 0); TestFlowElement tCond = flowchart1.AddConditionalLink(null, flowDecision, w2True, w2False); flowchart1.Elements.Add(tCond); TestRuntime.RunAndValidateWorkflow(flowchart1); }
public void SimpleDoWhileConditionTrueSetToFalse() { TestSequence outerSequence = new TestSequence("sequence1"); TestSequence innerSequence = new TestSequence("inner seq"); TestAssign <int> o1o = new TestAssign <int>("Hong"); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestDoWhile doWhile = new TestDoWhile("do while") { ConditionExpression = ((env) => ((int)counter.Get(env)) == 0), Body = innerSequence, HintIterationCount = 1, }; TestWriteLine writeLine = new TestWriteLine("write hello"); writeLine.Message = "The world is changing all the time"; o1o.ToVariable = counter; // Use the mod make it as Zero-One-Zero. o1o.ValueExpression = ((env) => ((((int)counter.Get(env))) + 1) % 2); innerSequence.Activities.Add(writeLine); innerSequence.Activities.Add(o1o); outerSequence.Variables.Add(counter); outerSequence.Activities.Add(doWhile); TestRuntime.RunAndValidateWorkflow(outerSequence); }
public void SimpleDoWhileConditionFalseSetToTrue() { // Test case description: // Set condition to a valid rule and run with an activity in it. Condition is false initially, then set to // true in the do part. TestSequence outerSequence = new TestSequence("sequence1"); TestSequence innerSequence = new TestSequence("inner sequence"); TestAssign <int> o1o = new TestAssign <int>("Hong"); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestDoWhile doWhile = new TestDoWhile("do while") { ConditionExpression = ((env) => (counter.Get(env) == 1)), Body = innerSequence, HintIterationCount = 2, }; TestWriteLine writeLine = new TestWriteLine("write hello"); writeLine.Message = "set the counter to be 1"; o1o.ToVariable = counter; // Use the mod make it as Zero-One-Zero. o1o.ValueExpression = ((env) => (counter.Get(env) + 1) % 2); innerSequence.Activities.Add(writeLine); innerSequence.Activities.Add(o1o); outerSequence.Variables.Add(counter); outerSequence.Activities.Add(doWhile); TestRuntime.RunAndValidateWorkflow(outerSequence); }
public void SimpleWhileConditionTrue() { // Test case description: // Set condition to a valid rule and run with an activity in it. Condition is true - IMPLEMENTED IN BASIC WHILETEST TestSequence outerSequence = new TestSequence("sequence1"); TestSequence innerSequence = new TestSequence("Seq"); TestIncrement increment = new TestIncrement("test increment"); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestWhile whileAct = new TestWhile("while act") { ConditionExpression = ((env) => ((int)counter.Get(env)) < 10), Body = innerSequence, HintIterationCount = 10, }; TestWriteLine writeLine = new TestWriteLine("write hello") { Message = "Its a small world after all" }; increment.CounterVariable = counter; innerSequence.Activities.Add(writeLine); innerSequence.Activities.Add(increment); outerSequence.Variables.Add(counter); outerSequence.Activities.Add(whileAct); TestRuntime.RunAndValidateWorkflow(outerSequence); }
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 Flowchart_Forloop() { TestFlowchart flowchart = new TestFlowchart("Flow1"); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); flowchart.Variables.Add(counter); TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1"); TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2"); TestAssign <int> assign = new TestAssign <int>("Assign1"); assign.ValueExpression = ((env) => ((int)counter.Get(env)) + 1); assign.ToVariable = counter; List <HintTrueFalse> hints = new List <HintTrueFalse>(); for (int i = 0; i < 49; i++) { hints.Add(HintTrueFalse.True); } hints.Add(HintTrueFalse.False); TestFlowConditional flowDecision = new TestFlowConditional(hints.ToArray()); flowDecision.ConditionExpression = (context => counter.Get(context) < 50); flowchart.AddLink(writeLine1, assign); flowchart.AddConditionalLink(assign, flowDecision, assign, writeLine2); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void Flowchart_DoWhile() { TestFlowchart flowchart = new TestFlowchart(); Variable <int> counter = VariableHelper.CreateInitialized <int>(0); counter.Name = "counter"; flowchart.Variables.Add(counter); List <HintTrueFalse> hintsList = new List <HintTrueFalse>(); for (int i = 0; i < 9; i++) { hintsList.Add(HintTrueFalse.True); } hintsList.Add(HintTrueFalse.False); TestFlowConditional conditional = new TestFlowConditional(hintsList.ToArray()) { ConditionExpression = env => counter.Get(env) < 10 }; TestWriteLine start = new TestWriteLine("Start", "Flowchart Started"); TestIncrement incrementByOne = new TestIncrement() { CounterVariable = counter, IncrementCount = 1 }; flowchart.AddLink(start, incrementByOne); flowchart.AddConditionalLink(incrementByOne, conditional, incrementByOne, new TestWriteLine("Final", "End")); TestRuntime.RunAndValidateWorkflow(flowchart); }
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); }
/// <summary> /// TryCatchfinally that throws from the catch that doesn’t catch /// </summary> /// Disabled and failed in desktop //[Fact] public void TryCatchFinallyWithExceptionInUncatchingCatch() { // try TestSequence trySeq = new TestSequence("Try"); trySeq.Activities.Add(new TestThrow <ArgumentException>("ThrowFromInner")); // catch TestCatch[] catches = new TestCatch[] { new TestCatch <ArgumentException>() { HintHandleException = true, Body = new TestWriteLine("Catch", "Catch") }, new TestCatch <UnauthorizedAccessException>() { HintHandleException = false, Body = new TestThrow <UnauthorizedAccessException>("Throw from uncalled catch") } }; // finally TestWriteLine finalWrite = new TestWriteLine("Final", "Final"); // Run test TestRuntime.RunAndValidateWorkflow (CreateTryCatchFinally(trySeq, catches, finalWrite, WFType.SEQ, false)); }
public void SimpleFlowSwitchWithThreeElements() { TestFlowchart flowchart = new TestFlowchart(); Variable <int> expression = new Variable <int> { Name = "expression", Default = 2 }; flowchart.Variables.Add(expression); TestWriteLine w1 = new TestWriteLine("One", "One wont execute"); TestWriteLine w2 = new TestWriteLine("Two", "Two will execute"); TestWriteLine w3 = new TestWriteLine("Three", "Three wont execute"); Dictionary <int, TestActivity> cases = new Dictionary <int, TestActivity>(); cases.Add(1, w1); cases.Add(2, w2); cases.Add(3, w3); List <int> hints = new List <int>(); hints.Add(1); flowchart.AddSwitchLink <int>(new TestWriteLine("Start", "Flowchart started"), cases, hints, expression, new TestWriteLine("Default", "Default")); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void ThrowExceptionInElseBody() { // Test case description: // 2 bracnhes:throw exception in the condition throw exception in if body, else executingthrow exception // in else body if executingthrow exception in both branches if executingthrow exception in both branches // else executing TestSequence outerSequence = new TestSequence("sequence1"); TestSequence innerSequence = new TestSequence("inner seq"); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestWriteLine writeLine = new TestWriteLine("write hello") { Message = "Its a small world after all" }; TestIf ifAct = new TestIf("if act", HintThenOrElse.Else) { ConditionExpression = ((env) => ((int)counter.Get(env)) > 10), ThenActivity = new TestSequence("sequence in if"), ElseActivity = innerSequence }; TestThrow <ArithmeticException> throwArt = new TestThrow <ArithmeticException>("throw"); innerSequence.Activities.Add(throwArt); outerSequence.Activities.Add(ifAct); innerSequence.Activities.Add(writeLine); outerSequence.Variables.Add(counter); TestRuntime.RunAndValidateAbortedException(outerSequence, typeof(ArithmeticException), new Dictionary <string, string>()); }
public void ThrowFromNode() { TestFlowchart flowchart = new TestFlowchart(); Variable <int> expression = new Variable <int> { Name = "expression", Default = 3 }; flowchart.Variables.Add(expression); TestWriteLine w1 = new TestWriteLine("One", "One wont execute"); TestWriteLine w2 = new TestWriteLine("Two", "Two will execute"); TestThrow <Exception> throwAct = new TestThrow <Exception>(); Dictionary <int, TestActivity> cases = new Dictionary <int, TestActivity>(); cases.Add(1, w1); cases.Add(2, w2); cases.Add(3, throwAct); List <int> hints = new List <int>(); hints.Add(2); flowchart.AddSwitchLink <int>(new TestWriteLine("Start", "Flowchart started"), cases, hints, expression, new TestWriteLine("Default", "Default")); TestRuntime.RunAndValidateAbortedException(flowchart, typeof(Exception), null); }
public void FlowSwitchWithAllCasesHavingSameElement() { TestFlowchart flowchart = new TestFlowchart(); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); flowchart.Variables.Add(counter); TestIncrement increment = new TestIncrement("Inc", 1) { CounterVariable = counter }; TestWriteLine writeHello = new TestWriteLine("Hello", "Ola"); Dictionary <object, TestActivity> cases = new Dictionary <object, TestActivity>(); cases.Add(1, writeHello); cases.Add(2, writeHello); cases.Add(3, writeHello); List <int> hints = new List <int>() { 0, 1, 2, -1 }; flowchart.AddLink(new TestWriteLine("Start", "Flowchart Started"), increment); flowchart.AddSwitchLink(increment, cases, hints, e => counter.Get(e)); flowchart.AddLink(writeHello, increment); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void MultipleActivitiesInLoop() { TestFlowchart flowchart = new TestFlowchart("Flow1"); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); flowchart.Variables.Add(counter); TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1"); TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2"); TestWriteLine writeLine3 = new TestWriteLine("hello3", "Hello3"); TestAssign <int> assign = new TestAssign <int>("Assign1") { ValueExpression = ((env) => counter.Get(env) + 1), ToVariable = counter }; List <HintTrueFalse> hints = new List <HintTrueFalse>(); hints.Add(HintTrueFalse.False); hints.Add(HintTrueFalse.False); hints.Add(HintTrueFalse.True); TestFlowConditional flowDecision = new TestFlowConditional(hints.ToArray()) { ConditionExpression = (context => counter.Get(context) == 3) }; flowchart.AddLink(writeLine1, assign); flowchart.AddLink(assign, writeLine2); flowchart.AddConditionalLink(writeLine2, flowDecision, writeLine3, assign); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void PersistFlowchart() { TestFlowchart flowchart = new TestFlowchart(); TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1"); TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2"); TestBlockingActivity blocking = new TestBlockingActivity("BlockingActivity"); flowchart.AddStartLink(writeLine1); flowchart.AddLink(writeLine1, blocking); flowchart.AddLink(blocking, writeLine2); JsonFileInstanceStore.FileInstanceStore jsonStore = new JsonFileInstanceStore.FileInstanceStore(".\\~"); using (TestWorkflowRuntime testWorkflowRuntime = TestRuntime.CreateTestWorkflowRuntime(flowchart, null, jsonStore, PersistableIdleAction.None)) { testWorkflowRuntime.ExecuteWorkflow(); testWorkflowRuntime.WaitForActivityStatusChange("BlockingActivity", TestActivityInstanceState.Executing); testWorkflowRuntime.PersistWorkflow(); System.Threading.Thread.Sleep(2000); testWorkflowRuntime.ResumeBookMark("BlockingActivity", null); testWorkflowRuntime.WaitForCompletion(); } }
public void SimpleIfThenOnly() { TestSequence outerSequence = new TestSequence("sequence1"); TestSequence innerSequence = new TestSequence("innerseq"); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestSequence ifSequence = new TestSequence("ifSequence"); TestWriteLine writeLine = new TestWriteLine("write hello") { Message = "Its a small world after all" }; TestIf ifAct = new TestIf("if act", HintThenOrElse.Then) { ConditionExpression = ((env) => ((int)counter.Get(env)) < 10), ThenActivity = innerSequence, }; ifSequence.Activities.Add(ifAct); innerSequence.Activities.Add(writeLine); outerSequence.Variables.Add(counter); outerSequence.Activities.Add(ifSequence); TestRuntime.RunAndValidateWorkflow(outerSequence); }
public void ThrowWhileEvaluatingExpression() { TestFlowchart flowchart = new TestFlowchart(); TestWriteLine writeHello = new TestWriteLine("Hello", "Hello"); TestWriteLine writeStart = new TestWriteLine("Start", "Start"); TestExpressionEvaluatorWithBody <string> expressionActivity = new TestExpressionEvaluatorWithBody <string>("One") { Body = new TestThrow <ArgumentOutOfRangeException>() }; Dictionary <string, TestActivity> cases = new Dictionary <string, TestActivity>(); cases.Add("One", new TestWriteLine("One", "One will not execute")); cases.Add("Two", new TestWriteLine("Two", "Two will not execute")); List <int> hints = new List <int>() { -1 }; flowchart.AddStartLink(writeStart); flowchart.AddSwitchLink <string>(writeStart, cases, hints, expressionActivity, new TestWriteLine("Default", "Will not execute")); TestRuntime.RunAndValidateAbortedException(flowchart, typeof(ArgumentOutOfRangeException), null); }
public void CancelExecutingChildActivities() { TestFlowchart parent = new TestFlowchart("Parent"); TestBlockingActivity blocking = new TestBlockingActivity("BlockingActivity", "B1"); TestWriteLine writeLine1 = new TestWriteLine("w1", "w1"); TestWriteLine writeLine2 = new TestWriteLine("w2", "w2"); parent.AddLink(writeLine1, blocking); TestFlowElement element = parent.AddLink(blocking, writeLine2); element.IsCancelling = true; blocking.ExpectedOutcome = Outcome.Canceled; parent.ExpectedOutcome = Outcome.Canceled; using (TestWorkflowRuntime testWorkflowRuntime = TestRuntime.CreateTestWorkflowRuntime(parent)) { testWorkflowRuntime.ExecuteWorkflow(); testWorkflowRuntime.WaitForActivityStatusChange("BlockingActivity", TestActivityInstanceState.Executing); testWorkflowRuntime.CancelWorkflow(); System.Threading.Thread.Sleep(2000); testWorkflowRuntime.WaitForCanceled(); } }
public void FlowStepAndFlowSwitchNotConnected() { TestFlowchart flowchart1 = new TestFlowchart("flowChart1"); TestWriteLine start1 = new TestWriteLine("Start", "Executing Start"); TestWriteLine w1 = new TestWriteLine("W1", "Executing W1"); TestWriteLine w2 = new TestWriteLine("W2", "Executing W2"); TestWriteLine w3 = new TestWriteLine("W3", "Executing W3"); TestWriteLine wDefault = new TestWriteLine("wDefault", "Executing wDefault"); TestFlowStep flowStep1 = new TestFlowStep(w1); Dictionary <string, TestActivity> cases = new Dictionary <string, TestActivity>(); cases.Add("One", w2); cases.Add("Two", w3); List <int> hints = new List <int>(); hints.Add(1); TestFlowElement flowSwitch1 = flowchart1.AddSwitchLink <string>(null, cases, hints, "Two", wDefault); flowchart1.Elements.Add(flowStep1); TestRuntime.RunAndValidateWorkflow(flowchart1); }
public void SameActivityMultipleTimesInSameSequence() { // Test case description: // Add same activity multiple times to same sequence TestSequence sequence = new TestSequence("ContainerSequence"); TestSequence sequence2 = new TestSequence("Seq"); TestWriteLine writeLine1 = new TestWriteLine("Hello One"); writeLine1.Message = "Hello world!"; TestWriteLine writeLine2 = new TestWriteLine("Hello Two"); writeLine2.Message = "Hello world!"; //begin:same sequence object with default name in a sequence sequence.Activities.Add(sequence2); sequence.Activities.Add(sequence2); //end:same sequence object with default name in a sequence TestRuntime.ValidateInstantiationException(sequence, string.Format(ErrorStrings.ActivityCannotBeReferencedWithoutTarget, sequence2.DisplayName, sequence.DisplayName, sequence.DisplayName)); }
public void FlowDecisionConnectedToFlowSwitch() { TestFlowchart flowchart = new TestFlowchart("Flow1"); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 3); flowchart.Variables.Add(counter); TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1"); TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2"); TestWriteLine w1 = new TestWriteLine("WriteLine1", "Executing WriteLine1"); TestWriteLine w2 = new TestWriteLine("WriteLine2", "Executing WriteLine2"); TestWriteLine w3 = new TestWriteLine("WriteLine3", "Executing WriteLine3"); TestWriteLine wDefault = new TestWriteLine("wDefault", "Executing wDefault"); TestFlowConditional flowDecision = new TestFlowConditional(HintTrueFalse.False) { ConditionExpression = (context => counter.Get(context) > 4) }; Dictionary <string, TestActivity> cases = new Dictionary <string, TestActivity>(); cases.Add("One", w1); cases.Add("Two", w2); cases.Add("Three", w3); List <int> hints = new List <int>(); hints.Add(1); TestFlowElement switchElement = flowchart.AddSwitchLink <string>(null, cases, hints, "Two", wDefault); flowchart.AddConditionalLink(writeLine1, flowDecision, writeLine2, switchElement); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void ConnectFromFlowconditionalBothTrueAndFalseToSameFlowconditional() { TestFlowchart flowchart = new TestFlowchart(); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); flowchart.Variables.Add(counter); TestWriteLine w1 = new TestWriteLine("w1", "w1"); TestWriteLine w2 = new TestWriteLine("w2", "w2"); TestAssign <int> assign = new TestAssign <int>("assign") { ValueExpression = (e => counter.Get(e) + 1), ToVariable = counter }; TestFlowConditional conditional1 = new TestFlowConditional(HintTrueFalse.False) { ConditionExpression = (e => counter.Get(e) == 5) }; TestFlowConditional conditional2 = new TestFlowConditional(HintTrueFalse.False) { ConditionExpression = (e => counter.Get(e) == 5) }; flowchart.AddLink(w1, assign); flowchart.AddConditionalLink(assign, conditional1); flowchart.AddConditionalLink(null, conditional2, assign, w2); flowchart.AddConditionalLink(null, conditional1, conditional2, conditional2); TestRuntime.RunAndValidateWorkflow(flowchart); }
/// <summary> /// Setup a t/c/f statement. /// </summary> /// <param name="tryBody">Try activity.</param> /// <param name="tc">Array of Catches.</param> /// <param name="finallyBody">Finally activity.</param> /// <param name="type">Type of workflow to create.</param> /// <param name="otherActivities">Flag indicating whether extra activities should be added.</param> public static TestActivity CreateTryCatchFinally(TestActivity tryBody, TestCatch[] tc, TestActivity finallyBody, WFType type, bool otherActivities) { // create the try/catch/finally TestTryCatch tcf = new TestTryCatch("TestTcf"); if (tryBody != null) { tcf.Try = tryBody; } if (tc != null) { foreach (TestCatch testCatch in tc) { tcf.Catches.Add(testCatch); } } if (finallyBody != null) { tcf.Finally = finallyBody; } // extra activities to add around activity if otherActivities is true TestWriteLine before = new TestWriteLine("BeforeTry", "BeforeTry"); TestWriteLine after = new TestWriteLine("AfterTry", "AfterTry"); // sequence if (type == WFType.SEQ) { TestSequence seq = new TestSequence("SequenceOfActivitiesContainingTCF"); if (otherActivities) { seq.Activities.Add(before); } seq.Activities.Add(tcf); if (otherActivities) { seq.Activities.Add(after); } return(seq); } // otherwise do flowchart else // type == wfType.FLOW { TestFlowchart flowchart = new TestFlowchart("FlowchartContainingTCF"); if (otherActivities) { flowchart.AddStartLink(before); flowchart.AddLink(before, tcf); flowchart.AddLink(tcf, after); } else { flowchart.AddStartLink(tcf); } return(flowchart); } }
public void FlowStepWithNullNext() { TestFlowchart flowchart1 = new TestFlowchart("flowChart1"); TestWriteLine w1 = new TestWriteLine("writeLine1", "Executing writeLine1"); flowchart1.AddStartLink(w1); TestRuntime.RunAndValidateWorkflow(flowchart1); }
public void ExecuteSameActivityMultipleTimesInDifferentFlowSteps() { TestFlowchart flowchart = new TestFlowchart(); TestWriteLine writeLine = new TestWriteLine("Hello", "Hello"); flowchart.AddLink(writeLine, writeLine); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void ExecuteSingleActivity() { TestFlowchart flowchart = new TestFlowchart("Flowchart"); TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1"); flowchart.AddStartLink(writeLine1); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void DisplayNameNull() { TestFlowchart flowchart = new TestFlowchart(); TestWriteLine w1 = new TestWriteLine("w1", "Hello1"); flowchart.AddStartLink(w1); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void FlowSwitchInLoopSameCaseEvaluation() { TestFlowchart flowchart = new TestFlowchart(); Variable <int> switchVariable = VariableHelper.CreateInitialized <int>("switchVar", 0); Variable <int> ifVariable = VariableHelper.CreateInitialized <int>("ifVar", 0); flowchart.Variables.Add(switchVariable); flowchart.Variables.Add(ifVariable); TestIncrement incrementIfVariable = new TestIncrement("Inc", 1) { CounterVariable = ifVariable }; TestIncrement incrementSwitchVariable = new TestIncrement("IncSwitch", 1) { CounterVariable = switchVariable }; TestWriteLine writeBegin = new TestWriteLine("Loop", "Looping"); List <HintTrueFalse> hintsList = new List <HintTrueFalse>(); for (int i = 0; i < 5; i++) { hintsList.Add(HintTrueFalse.True); } hintsList.Add(HintTrueFalse.False); TestFlowConditional conditional = new TestFlowConditional(hintsList.ToArray()) { ConditionExpression = env => ifVariable.Get(env) < 5 }; Dictionary <object, TestActivity> cases = new Dictionary <object, TestActivity>(); cases.Add(0, writeBegin); List <int> hints = new List <int>(); for (int i = 0; i < 5; i++) { hints.Add(0); } hints.Add(-1); flowchart.AddLink(new TestWriteLine("Start", "Flowchart started"), writeBegin); flowchart.AddConditionalLink(writeBegin, conditional, incrementIfVariable, incrementSwitchVariable); TestFlowSwitch <object> flowSwitch = flowchart.AddSwitchLink <object>(incrementIfVariable, cases, hints, env => switchVariable.Get(env), new TestWriteLine("Default", "Default")) as TestFlowSwitch <object>; flowchart.AddLink(incrementSwitchVariable, flowSwitch); TestRuntime.RunAndValidateWorkflow(flowchart); }
//[HostWorkflowAsWebService] public void IfInWhileSometimesIfThenTrueSometimesElseTrue() { Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestWriteLine writeTrue = new TestWriteLine("writeTrue") { Message = "I say you are RIGHT!" }; TestWriteLine writeFalse = new TestWriteLine("writeFalse") { Message = "I say you are WRONG!" }; TestIf ifAct = new TestIf("if act", HintThenOrElse.Then, HintThenOrElse.Else, HintThenOrElse.Then, HintThenOrElse.Else) { ConditionExpression = ((env) => ((int)counter.Get(env)) % 2 == 0), ThenActivity = writeTrue, ElseActivity = writeFalse, }; TestAssign <int> increment = new TestAssign <int>("Add One") { ToVariable = counter, ValueExpression = (env) => (((int)counter.Get(env))) + 1 }; TestSequence sequence = new TestSequence("innerSequence"); sequence.Activities.Add(ifAct); sequence.Activities.Add(increment); TestWhile whileAct = new TestWhile("while act") { ConditionExpression = (env) => ((int)counter.Get(env)) < 4, Body = sequence, HintIterationCount = 4, }; TestSequence rootSequence = new TestSequence("rootSequence"); rootSequence.Activities.Add(whileAct); rootSequence.Variables.Add(counter); TestRuntime.RunAndValidateWorkflow(rootSequence); }