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"); assign.ValueExpression = ((env) => counter.Get(env) + 1); assign.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()); flowDecision.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 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 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(); } }
/// <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 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); }
public void Flowchart_Sequence() { TestFlowchart flowchart = new TestFlowchart("Flow1"); TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1"); TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2"); TestWriteLine writeLine3 = new TestWriteLine("hello3", "Hello3"); TestWriteLine writeLine4 = new TestWriteLine("hello4", "Hello4"); flowchart.AddLink(writeLine1, writeLine2); flowchart.AddLink(writeLine2, writeLine3); flowchart.AddLink(writeLine3, writeLine4); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void LinkFromNestedFlowchartToParent() { TestFlowchart parent = new TestFlowchart("Parent"); TestFlowchart child = new TestFlowchart("Child"); TestWriteLine w1 = new TestWriteLine("w1", "w1"); TestWriteLine w2 = new TestWriteLine("w2", "w2"); TestWriteLine w3 = new TestWriteLine("w3", "w3"); parent.AddLink(w1, w2); parent.AddLink(w2, child); child.AddLink(w3, w2); TestRuntime.ValidateInstantiationException(parent, string.Format(ErrorStrings.ActivityCannotBeReferencedWithoutTarget, w2.DisplayName, child.DisplayName, parent.DisplayName)); }
public void CreateFlowlinkToActivityInNestedFlowchart() { // This testCase is a pair for: LinkFromNestedFlowchartToParent() TestFlowchart parentFlowchart = new TestFlowchart("Parent"); TestFlowchart childFlowchart = new TestFlowchart("Child"); TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1"); TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2"); parentFlowchart.AddLink(childFlowchart, writeLine1); parentFlowchart.AddLink(writeLine1, writeLine2); childFlowchart.AddStartLink(writeLine2); TestRuntime.ValidateInstantiationException(parentFlowchart, string.Format(ErrorStrings.ActivityCannotBeReferencedWithoutTarget, writeLine2.DisplayName, childFlowchart.DisplayName, parentFlowchart.DisplayName)); }
public void FlowchartVariableUseInLoop() { TestFlowchart flowchart = new TestFlowchart("Flow1"); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); flowchart.Variables.Add(counter); 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 < 9; i++) { hints.Add(HintTrueFalse.True); } hints.Add(HintTrueFalse.False); TestFlowConditional flowDecision = new TestFlowConditional(hints.ToArray()); flowDecision.ConditionExpression = (context => counter.Get(context) < 10); flowchart.AddLink(new TestWriteLine("Start", "Flowchart started"), assign); flowchart.AddConditionalLink(assign, flowDecision, assign, new TestWriteLine("End", "Flowchart ended")); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void ThreeActivitiesInOrJoin() { TestFlowchart flowchart = new TestFlowchart("Flow1"); Variable <int> counter = VariableHelper.CreateInitialized <int>(0); counter.Name = "counter"; flowchart.Variables.Add(counter); TestIncrement inc1 = new TestIncrement { CounterVariable = counter, IncrementCount = 1 }; TestIncrement inc2 = new TestIncrement { CounterVariable = counter, IncrementCount = 1 }; TestIncrement inc3 = new TestIncrement { CounterVariable = counter, IncrementCount = 1 }; TestParallel parallel = new TestParallel { Branches = { inc1, inc2, inc3 }, CompletionConditionExpression = env => counter.Get(env) == 1, HintNumberOfBranchesExecution = 1 }; flowchart.AddLink(parallel, new TestWriteLine("End", "The End")); TestRuntime.RunAndValidateWorkflow(flowchart); }
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") { ValueExpression = ((env) => ((int)counter.Get(env)) + 1), 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()) { ConditionExpression = (context => counter.Get(context) < 50) }; flowchart.AddLink(writeLine1, assign); flowchart.AddConditionalLink(assign, flowDecision, assign, writeLine2); 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); }
public void AccessVariableOnParentFromNestedFlowchart() { TestFlowchart parent = new TestFlowchart(); TestFlowchart child = new TestFlowchart(); Variable <int> counter = VariableHelper.CreateInitialized <int>(2); counter.Name = "counter"; parent.Variables.Add(counter); Dictionary <object, TestActivity> cases = new Dictionary <object, TestActivity>(); cases.Add(1, new TestWriteLine("One", "One")); cases.Add(2, new TestWriteLine("Two", "Two")); cases.Add(3, new TestWriteLine("Three", "Three")); List <int> hints = new List <int> { 1 }; child.AddSwitchLink(new TestWriteLine("Child Started", "Child Started"), cases, hints, e => counter.Get(e), new TestWriteLine("Default", "Default")); parent.AddLink(new TestWriteLine("Start", "Parent started"), child); TestRuntime.RunAndValidateWorkflow(parent); }
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 FaultWhileExecutingInLoop() { TestFlowchart flowchart = new TestFlowchart(); Variable <int> counter = VariableHelper.CreateInitialized <int>(-3); counter.Name = "counter"; flowchart.Variables.Add(counter); List <HintTrueFalse> hints = new List <HintTrueFalse> { HintTrueFalse.True, HintTrueFalse.True, HintTrueFalse.Exception }; TestFlowConditional conditional = new TestFlowConditional(hints.ToArray()) { ConditionExpression = env => (counter.Get(env) - 1) / counter.Get(env) > 0 }; TestIncrement decByOne = new TestIncrement { CounterVariable = counter, IncrementCount = 1 }; flowchart.AddLink(new TestWriteLine("Start", "Start"), decByOne); flowchart.AddConditionalLink(decByOne, conditional, decByOne, null); TestRuntime.RunAndValidateAbortedException(flowchart, typeof(DivideByZeroException), null); }
public void ConditionExpressionDivideByZero() { Variable <int> counter1 = VariableHelper.CreateInitialized <int>("counter1", 0); Variable <int> counter2 = VariableHelper.CreateInitialized <int>("counter2", 2); TestFlowchart flowchart = new TestFlowchart("Flowchart") { Variables = { counter1, counter2 }, ExpectedOutcome = Outcome.UncaughtException(typeof(DivideByZeroException)) }; flowchart.ExpectedOutcome.IsOverrideable = true; TestAssign <int> assign = new TestAssign <int>("Assign") { ValueExpression = ((env) => (counter1.Get(env) + 1)), ToExpression = ((env) => counter2.Get(env)) }; TestFlowConditional flowDecision = new TestFlowConditional(HintTrueFalse.Exception) { ConditionExpression = ((env) => counter1.Get(env) / (counter2.Get(env) - 1) >= 0), }; flowchart.AddLink(new TestWriteLine("Start", "Flowchart Started"), assign); flowchart.AddConditionalLink(assign, flowDecision, assign, (TestActivity)null); TestRuntime.RunAndValidateAbortedException(flowchart, typeof(DivideByZeroException), null); }
public void NestedFlowchartInLoop() { TestFlowchart parentFlowchart = new TestFlowchart("ParentFlowchart"); TestFlowchart childFlowchart = new TestFlowchart("ChildFlowchart"); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); parentFlowchart.Variables.Add(counter); 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 < 5; i++) { hints.Add(HintTrueFalse.True); } hints.Add(HintTrueFalse.False); TestFlowConditional flowDecision = new TestFlowConditional(hints.ToArray()); flowDecision.ConditionExpression = (env => counter.Get(env) <= 5); parentFlowchart.AddLink(new TestWriteLine("Start", "Parent started"), childFlowchart); parentFlowchart.AddConditionalLink(childFlowchart, flowDecision, childFlowchart, new TestWriteLine("End", "Parent ended")); childFlowchart.AddStartLink(assign); TestRuntime.RunAndValidateWorkflow(parentFlowchart); }
public void FlowSwitchInLoopDefaultEvaluation() { TestFlowchart flowchart = new TestFlowchart(); Variable <int> counter = VariableHelper.CreateInitialized <int>(0); counter.Name = "counter"; flowchart.Variables.Add(counter); Dictionary <object, TestActivity> cases = new Dictionary <object, TestActivity>(); cases.Add(10, new TestWriteLine("Ten", "Ten")); cases.Add(11, new TestWriteLine("Eleven", "Eleven")); cases.Add(12, new TestWriteLine("Twelve", "Twelve")); cases.Add(13, new TestWriteLine("Thirteen", "Thirteen")); List <int> hints = new List <int>(); for (int i = 0; i < 10; i++) { hints.Add(-1); } hints.Add(0); TestIncrement incByOne = new TestIncrement { IncrementCount = 1, CounterVariable = counter }; TestFlowSwitch <object> flowSwitch = flowchart.AddSwitchLink <object>(new TestWriteLine("Start", "Flowchart started"), cases, hints, e => counter.Get(e), incByOne) as TestFlowSwitch <object>; flowchart.AddLink(incByOne, flowSwitch); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void FlowStepConnectedToFlowStep() { TestFlowchart flowchart = new TestFlowchart(); flowchart.AddLink(new TestWriteLine("Start", "Start"), new TestWriteLine("End", "End")); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void AddFlowchartToItself() { TestFlowchart flow = new TestFlowchart(); flow.AddLink(new TestWriteLine("w1", "w1"), flow); TestRuntime.ValidateInstantiationException(flow, string.Format(ErrorStrings.ActivityCannotReferenceItself, flow.DisplayName)); }
public void Flowchart_ForEach() { TestFlowchart flowchart = new TestFlowchart("Flow1"); List <int> tenInts = new List <int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; Variable <List <int> > listOfInts = new Variable <List <int> >("listOfInts", (env) => new List <int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); flowchart.Variables.Add(listOfInts); Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); flowchart.Variables.Add(counter); Variable <bool> boolVar = VariableHelper.CreateInitialized <bool>("boolVar", true); flowchart.Variables.Add(boolVar); Variable <IEnumerator <int> > intEnumerator = VariableHelper.Create <IEnumerator <int> >("intEnumerator"); flowchart.Variables.Add(intEnumerator); TestAssign <IEnumerator <int> > assign1 = new TestAssign <IEnumerator <int> >("Assign1"); assign1.ValueExpression = ((env) => ((List <int>)listOfInts.Get(env)).GetEnumerator()); assign1.ToVariable = intEnumerator; TestAssign <bool> assign2 = new TestAssign <bool>("Assign2"); assign2.ValueExpression = ((env) => ((IEnumerator <int>)intEnumerator.Get(env)).MoveNext()); assign2.ToVariable = boolVar; List <HintTrueFalse> hints = new List <HintTrueFalse>(); for (int i = 0; i < 10; i++) { hints.Add(HintTrueFalse.True); } hints.Add(HintTrueFalse.False); TestFlowConditional flowDecision = new TestFlowConditional(hints.ToArray()); flowDecision.ConditionExpression = (context => boolVar.Get(context) == true); flowchart.AddStartLink(assign1); flowchart.AddLink(assign1, assign2); flowchart.AddConditionalLink(assign2, flowDecision, assign2, new TestWriteLine("End", "Flowchart ended")); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void FlowStepWithNullAction() { TestFlowchart flowchart1 = new TestFlowchart("flowChart1"); TestWriteLine w1 = new TestWriteLine("writeLine1", "Executing writeLine1"); flowchart1.AddLink(null, w1); TestRuntime.RunAndValidateWorkflow(flowchart1); }
public void StartNodeNotInNodesCollection() { TestFlowchart flowchart = new TestFlowchart(); flowchart.AddLink(new TestWriteLine("Start", "Start"), new TestWriteLine("One", "One")); ((Act.Flowchart)flowchart.ProductActivity).Nodes.RemoveAt(0); Validate(flowchart, null); //No constraint violation }
public void ExecuteSameActivityMultipleTimesInDifferentFlowSteps() { TestFlowchart flowchart = new TestFlowchart(); TestWriteLine writeLine = new TestWriteLine("Hello", "Hello"); flowchart.AddLink(writeLine, writeLine); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void FlowStepActionToNestedActivityInSequence() { TestFlowchart flowchart = new TestFlowchart(); TestWriteLine w1 = new TestWriteLine("w1", "w1"); TestWriteLine w2 = new TestWriteLine("w2", "w2"); TestWriteLine w3 = new TestWriteLine("w3", "w3"); TestSequence seq = new TestSequence(); seq.Activities.Add(w2); flowchart.AddLink(w1, seq); flowchart.AddLink(seq, w3); flowchart.AddLink(w3, w2); TestRuntime.ValidateInstantiationException(flowchart, string.Format(ErrorStrings.ActivityCannotBeReferencedWithoutTarget, w2.DisplayName, seq.DisplayName, flowchart.DisplayName)); }
public void ValidStartNodeWithNodeCollectionEmpty() { TestFlowchart flowchart = new TestFlowchart(); flowchart.AddLink(new TestWriteLine("One", "One"), new TestWriteLine("Two", "Two")); ((System.Activities.Statements.Flowchart)flowchart.ProductActivity).Nodes.Clear(); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void GetChildrenModifyChildrenExecute() { TestFlowchart flowchart = new TestFlowchart("Flow1"); TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1"); TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2"); TestWriteLine writeLine3 = new TestWriteLine("hello3", "Hello3"); TestWriteLine writeLine4 = new TestWriteLine("hello4", "Hello4"); flowchart.AddLink(writeLine1, writeLine2); flowchart.AddLink(writeLine2, writeLine3); WorkflowInspectionServices.GetActivities(flowchart.ProductActivity); flowchart.AddLink(writeLine3, writeLine4); // Now that we've change the tree we need to explicitly recache WorkflowInspectionServices.CacheMetadata(flowchart.ProductActivity); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void Flowchart_Parallel() { TestFlowchart flowchart = new TestFlowchart("Flow1"); TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1"); TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2"); TestWriteLine writeLine3 = new TestWriteLine("hello3", "Hello3"); TestWriteLine writeLine4 = new TestWriteLine("hello4", "Hello4"); TestWriteLine writeLine5 = new TestWriteLine("hello5", "Hello5"); TestParallel parallel = new TestParallel { Branches = { writeLine2, writeLine3, writeLine4 } }; flowchart.AddLink(writeLine1, parallel); flowchart.AddLink(parallel, writeLine5); TestRuntime.RunAndValidateWorkflow(flowchart); }
public void FlowSwitchWithNodePointingToParentFlowSwitch() { 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 w1 = new TestWriteLine("One", "Will execute on first iteration"); TestWriteLine w2 = new TestWriteLine("Two", "Will execute on second iteration"); TestWriteLine w3 = new TestWriteLine("Three", "Will execute on third iteration"); TestWriteLine w4 = new TestWriteLine("Four", "Will execute on final iteration"); 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(0); hints.Add(1); hints.Add(2); hints.Add(-1); flowchart.AddLink(new TestWriteLine("Start", "Flowchart Started"), increment); flowchart.AddSwitchLink <int>(increment, cases, hints, env => counter.Get(env), w4); flowchart.AddLink(w1, increment); flowchart.AddLink(w2, increment); flowchart.AddLink(w3, increment); TestRuntime.RunAndValidateWorkflow(flowchart); }