示例#1
0
        /// <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);
            }
        }
示例#2
0
        /// <summary>
        /// Exception thrown from 5 level deep nested flowchart and handled at the top level.
        /// </summary>
        //[Fact]
        public void FaultFromFiveLevelDeepNestedFlowchart_Handled()
        {
            TestFlowchart parent = new TestFlowchart();
            TestFlowchart child1 = new TestFlowchart();
            TestFlowchart child2 = new TestFlowchart();
            TestFlowchart child3 = new TestFlowchart();
            TestFlowchart child4 = new TestFlowchart();

            child4.AddStartLink(new TestThrow <WorkflowApplicationAbortedException>()
            {
                ExpectedOutcome = Outcome.CaughtException()
            });

            child1.AddStartLink(child2);
            child2.AddStartLink(child3);
            child3.AddStartLink(child4);

            TestTryCatch tryCatchFinally = new TestTryCatch();

            tryCatchFinally.Try = child1;
            tryCatchFinally.Catches.Add(new TestCatch <WorkflowApplicationAbortedException>());

            parent.AddStartLink(tryCatchFinally);

            TestRuntime.RunAndValidateWorkflow(parent);
        }
示例#3
0
        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();
            }
        }
示例#4
0
        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);
        }
示例#5
0
        public void UnloadFlowchartWhileExecutingFlowStep()
        {
            TestFlowchart flowchart = new TestFlowchart();

            TestBlockingActivity blocking = new TestBlockingActivity("Block");

            flowchart.AddStartLink(blocking);

            JsonFileInstanceStore.FileInstanceStore jsonStore = new JsonFileInstanceStore.FileInstanceStore(".\\~");

            using (TestWorkflowRuntime testWorkflowRuntime = TestRuntime.CreateTestWorkflowRuntime(flowchart, null, jsonStore, PersistableIdleAction.Unload))
            {
                testWorkflowRuntime.ExecuteWorkflow();

                testWorkflowRuntime.WaitForActivityStatusChange(blocking.DisplayName, TestActivityInstanceState.Executing);

                testWorkflowRuntime.UnloadWorkflow();

                testWorkflowRuntime.LoadWorkflow();


                testWorkflowRuntime.ResumeBookMark("Block", null);

                testWorkflowRuntime.WaitForCompletion();
            }
        }
示例#6
0
        /// <summary>
        /// Five level deep nested flowchart with blocking activity
        /// </summary>
        /// Disabled and failed in desktop
        //[Fact]
        public void FiveLevelDeepNestedFlowchartWithBlockingActivity()
        {
            TestFlowchart        parent   = new TestFlowchart();
            TestFlowchart        child1   = new TestFlowchart();
            TestFlowchart        child2   = new TestFlowchart();
            TestFlowchart        child3   = new TestFlowchart();
            TestFlowchart        child4   = new TestFlowchart();
            TestBlockingActivity blocking = new TestBlockingActivity("Blocked");

            parent.AddStartLink(child1);
            child1.AddStartLink(child2);
            child2.AddStartLink(child3);
            child3.AddStartLink(child4);
            child4.AddStartLink(blocking);

            using (TestWorkflowRuntime testWorkflowRuntime = TestRuntime.CreateTestWorkflowRuntime(parent))
            {
                testWorkflowRuntime.ExecuteWorkflow();

                testWorkflowRuntime.WaitForActivityStatusChange(blocking.DisplayName, TestActivityInstanceState.Executing);

                testWorkflowRuntime.ResumeBookMark("Blocked", null);

                testWorkflowRuntime.WaitForCompletion();
            }
        }
示例#7
0
        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);
        }
示例#8
0
        public void FlowchartInProceduralWhile()
        {
            TestSequence s = new TestSequence("seq1");

            Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0);

            s.Variables.Add(counter);

            TestWhile w = new TestWhile("While1");

            s.Activities.Add(w);

            TestFlowchart f = new TestFlowchart("Flow1");

            TestAssign <int> assign = new TestAssign <int>("Assign1");

            assign.ValueExpression = (env => ((int)counter.Get(env)) + 1);
            assign.ToVariable      = counter;

            w.ConditionExpression = (env => counter.Get(env) < 5);
            w.HintIterationCount  = 5;

            f.AddStartLink(assign);

            w.Body = f;

            TestRuntime.RunAndValidateWorkflow(s);
        }
示例#9
0
        public void FlowStepAsStartNode()
        {
            TestFlowchart flowchart = new TestFlowchart();

            flowchart.AddStartLink(new TestWriteLine("Begin", "End"));

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
示例#10
0
        public void FlowStepWithNullNext()
        {
            TestFlowchart flowchart1 = new TestFlowchart("flowChart1");
            TestWriteLine w1         = new TestWriteLine("writeLine1", "Executing writeLine1");

            flowchart1.AddStartLink(w1);
            TestRuntime.RunAndValidateWorkflow(flowchart1);
        }
示例#11
0
        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);
        }
示例#12
0
        public void DisplayNameNull()
        {
            TestFlowchart flowchart = new TestFlowchart();

            TestWriteLine w1 = new TestWriteLine("w1", "Hello1");

            flowchart.AddStartLink(w1);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
示例#13
0
        public void StartNodeNotInNodesCollection()
        {
            TestFlowchart flowchart = new TestFlowchart();

            flowchart.AddStartLink(new TestWriteLine("Hello", "Hello"));

            ((System.Activities.Statements.Flowchart)flowchart.ProductActivity).Nodes.Clear();

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
示例#14
0
        public void ExecuteSingleActivity()
        {
            TestFlowchart flowchart = new TestFlowchart("Flowchart");

            TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1");

            flowchart.AddStartLink(writeLine1);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
示例#15
0
        public void FlowchartContainingActivityWithColonInDisplayName()
        {
            TestDelay delay = new TestDelay
            {
                DisplayName = "001008 Delay 00:00:02.0000000",
                Duration    = new TimeSpan(0, 0, 2)
            };
            TestFlowchart flow = new TestFlowchart();

            flow.AddStartLink(delay);

            TestRuntime.RunAndValidateWorkflow(flow);
        }
示例#16
0
        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));
        }
示例#17
0
        public void ExecuteNestedFlowchart()
        {
            TestFlowchart parentFlowchart = new TestFlowchart("Parent");

            TestFlowchart childFlowchart = new TestFlowchart("Child");

            TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1");
            TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2");

            parentFlowchart.AddLink(writeLine1, childFlowchart);

            childFlowchart.AddStartLink(writeLine2);

            TestRuntime.RunAndValidateWorkflow(parentFlowchart);
        }
示例#18
0
        public void FiveLevelDeepEmptyNestedFlowchart()
        {
            TestFlowchart parent = new TestFlowchart();
            TestFlowchart child1 = new TestFlowchart();
            TestFlowchart child2 = new TestFlowchart();
            TestFlowchart child3 = new TestFlowchart();
            TestFlowchart child4 = new TestFlowchart();

            parent.AddStartLink(child1);
            child1.AddStartLink(child2);
            child2.AddStartLink(child3);
            child3.AddStartLink(child4);

            TestRuntime.RunAndValidateWorkflow(parent);
        }
示例#19
0
        public void DecisionTruePinConnectedConditionEvaluationFalse()
        {
            TestFlowchart flowchart = new TestFlowchart("Flow1");

            TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1");
            TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2");

            TestFlowConditional flowDecision = new TestFlowConditional(HintTrueFalse.False);

            flowDecision.Condition = false;

            flowchart.AddStartLink(writeLine1);
            flowchart.AddConditionalLink(writeLine1, flowDecision, (TestActivity)null, writeLine2);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
示例#20
0
        public void UnloadFlowchartWhileExecutingFlowSwitchExpression()
        {
            TestFlowchart flowchart = new TestFlowchart();

            TestWriteLine writeHello = new TestWriteLine("Hello", "Hello");

            TestWriteLine writeStart = new TestWriteLine("Start", "Start");

            TestExpressionEvaluatorWithBody <object> expressionActivity = new TestExpressionEvaluatorWithBody <object>
            {
                ExpressionResultExpression = context => "One",
                Body            = new TestBlockingActivity("Block"),
                WillBodyExecute = true
            };

            Dictionary <object, TestActivity> cases = new Dictionary <object, TestActivity>();

            cases.Add("One", writeHello);
            cases.Add("Two", new TestWriteLine("Two", "Two will not execute"));

            List <int> hints = new List <int>()
            {
                0
            };

            flowchart.AddStartLink(writeStart);

            flowchart.AddSwitchLink(writeStart, cases, hints, expressionActivity, new TestWriteLine("Default", "Will not execute"));

            JsonFileInstanceStore.FileInstanceStore jsonStore = new JsonFileInstanceStore.FileInstanceStore(".\\~");

            using (TestWorkflowRuntime testWorkflowRuntime = TestRuntime.CreateTestWorkflowRuntime(flowchart, null, jsonStore, PersistableIdleAction.Unload))
            {
                testWorkflowRuntime.ExecuteWorkflow();

                testWorkflowRuntime.WaitForActivityStatusChange(expressionActivity.DisplayName, TestActivityInstanceState.Executing);

                testWorkflowRuntime.UnloadWorkflow();

                testWorkflowRuntime.LoadWorkflow();

                testWorkflowRuntime.ResumeBookMark("Block", null);

                testWorkflowRuntime.WaitForCompletion();
            }
        }
示例#21
0
        public void TryAccessVariableInNestedFlowchartFromParent()
        {
            TestFlowchart parent = new TestFlowchart();
            TestFlowchart child  = new TestFlowchart();

            Variable <int> counter = VariableHelper.CreateInitialized <int>(0);

            child.Variables.Add(counter);

            parent.AddLink(new TestIncrement {
                IncrementCount = 1, CounterVariable = counter, ExpectedOutcome = Outcome.UncaughtException()
            }, child);

            child.AddStartLink(new TestWriteLine("Wont execute", "Will not execute"));

            TestRuntime.ValidateInstantiationException(parent, string.Format(ErrorStrings.VariableNotVisible, counter.Name));
        }
示例#22
0
        public void FlowStepAndFlowDecisionNotConnected()
        {
            TestFlowchart flowchart1 = new TestFlowchart("flowChart1");
            TestWriteLine w1         = new TestWriteLine("W1", "Executing W1");
            TestWriteLine w2         = new TestWriteLine("W2", "Executing W2");
            TestWriteLine w3         = new TestWriteLine("W3", "Executing W3");

            TestFlowConditional flowCond1 = new TestFlowConditional(HintTrueFalse.True);

            flowCond1.Condition = true;

            flowchart1.AddStartLink(w1);

            flowchart1.Elements.Add(flowCond1);

            TestRuntime.RunAndValidateWorkflow(flowchart1);
        }
示例#23
0
        public void FaultFromFiveLevelDeepNestedFlowchart()
        {
            TestFlowchart parent = new TestFlowchart();
            TestFlowchart child1 = new TestFlowchart();
            TestFlowchart child2 = new TestFlowchart();
            TestFlowchart child3 = new TestFlowchart();
            TestFlowchart child4 = new TestFlowchart();

            child4.AddStartLink(new TestThrow <WorkflowApplicationAbortedException>());

            parent.AddStartLink(child1);
            child1.AddStartLink(child2);
            child2.AddStartLink(child3);
            child3.AddStartLink(child4);

            TestRuntime.RunAndValidateAbortedException(parent, typeof(WorkflowApplicationAbortedException), null);
        }
示例#24
0
        public void ExpressionSetToFalse()
        {
            TestFlowchart flowchart = new TestFlowchart("Flow1");

            TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1");
            TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2");
            TestWriteLine writeLine3 = new TestWriteLine("hello3", "Hello3");

            TestFlowConditional flowDecision = new TestFlowConditional(HintTrueFalse.False);

            flowDecision.Condition = false;

            flowchart.AddStartLink(writeLine1);
            flowchart.AddConditionalLink(writeLine1, flowDecision, writeLine2, writeLine3);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
示例#25
0
        public void CancelFlowchartWhileEvaluatingFlowSwitchExpression()
        {
            TestFlowchart flowchart = new TestFlowchart();

            TestWriteLine writeHello = new TestWriteLine("Hello", "Hello");

            TestWriteLine writeStart = new TestWriteLine("Start", "Start");

            TestExpressionEvaluatorWithBody <object> expressionActivity = new TestExpressionEvaluatorWithBody <object>
            {
                ExpressionResultExpression = context => "One",
                Body = new TestBlockingActivity("B1", "Blocking")
                {
                    ExpectedOutcome = Outcome.Canceled
                },
                WillBodyExecute = true
            };

            Dictionary <object, TestActivity> cases = new Dictionary <object, TestActivity>();

            cases.Add("One", writeHello);

            List <int> hints = new List <int>()
            {
                -1
            };

            flowchart.AddStartLink(writeStart);

            flowchart.AddSwitchLink(writeStart, cases, hints, expressionActivity);

            flowchart.ExpectedOutcome          = Outcome.Canceled;
            expressionActivity.ExpectedOutcome = Outcome.Canceled;

            using (TestWorkflowRuntime testWorkflowRuntime = TestRuntime.CreateTestWorkflowRuntime(flowchart))
            {
                testWorkflowRuntime.ExecuteWorkflow();

                testWorkflowRuntime.WaitForActivityStatusChange("B1", TestActivityInstanceState.Executing);

                testWorkflowRuntime.CancelWorkflow();

                testWorkflowRuntime.WaitForCanceled(true);
            }
        }
示例#26
0
        public void FlowDecisionConnectedToFlowStep()
        {
            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 writeLine3 = new TestWriteLine("hello3", "Hello3");

            TestFlowConditional flowDecision = new TestFlowConditional(HintTrueFalse.True);

            flowDecision.ConditionExpression = (context => counter.Get(context) > 0);

            flowchart.AddStartLink(writeLine1);
            flowchart.AddConditionalLink(writeLine1, flowDecision, writeLine2, writeLine3);
            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
示例#27
0
        public void CancelFlowchart()
        {
            TestFlowchart flowchart = new TestFlowchart();

            TestBlockingActivity blocking1 = new TestBlockingActivity("B1", "B1");

            blocking1.ExpectedOutcome = Outcome.Canceled;

            flowchart.AddStartLink(blocking1);
            flowchart.ExpectedOutcome = Outcome.Canceled;

            using (TestWorkflowRuntime testWorkflowRuntime = TestRuntime.CreateTestWorkflowRuntime(flowchart))
            {
                testWorkflowRuntime.ExecuteWorkflow();
                testWorkflowRuntime.WaitForActivityStatusChange(blocking1.DisplayName, TestActivityInstanceState.Executing);

                testWorkflowRuntime.CancelWorkflow();

                testWorkflowRuntime.WaitForCanceled(true);
            }
        }
示例#28
0
        public void ConditionExpressionOnFlowchartVariable()
        {
            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 writeLine3 = new TestWriteLine("hello3", "Hello3");

            TestFlowConditional flowDecision = new TestFlowConditional
            {
                ConditionExpression = (context => counter.Get(context) == 3)
            };

            flowchart.AddStartLink(writeLine1);
            flowchart.AddConditionalLink(writeLine1, flowDecision, writeLine2, writeLine3);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
示例#29
0
        public void FlowSwitchConnectedToFlowDecision()
        {
            TestFlowchart flowchart = new TestFlowchart();

            TestWriteLine wStart   = new TestWriteLine("Start", "Flowchart started");
            TestWriteLine wDefault = new TestWriteLine("Default", "Default");
            TestWriteLine w1       = new TestWriteLine("One", "One wont execute");
            TestWriteLine w3       = new TestWriteLine("Three", "Three wont execute");
            TestWriteLine w2True   = new TestWriteLine("True", "True will execute");
            TestWriteLine w2False  = new TestWriteLine("False", "False wont execute");

            TestFlowStep fs1 = new TestFlowStep(w1);
            TestFlowStep fs3 = new TestFlowStep(w3);

            Variable <int> margin = VariableHelper.CreateInitialized <int>("Margin", 10);

            flowchart.Variables.Add(margin);
            TestFlowConditional flowDecision = new TestFlowConditional(HintTrueFalse.True)
            {
                ConditionExpression = (context => margin.Get(context) > 0)
            };

            flowchart.AddConditionalLink(null, flowDecision, w2True, w2False);

            Dictionary <string, TestFlowElement> cases = new Dictionary <string, TestFlowElement>();

            cases.Add("One", fs1);
            cases.Add("Two", flowDecision);
            cases.Add("Three", fs3);

            List <int> hints = new List <int>();

            hints.Add(1);

            flowchart.AddStartLink(wStart);
            flowchart.AddSwitchLink <string>(wStart, cases, hints, "Two", wDefault);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
示例#30
0
        /// <summary>
        /// Fault handled from flowchart in a try catch block.
        /// </summary>
        /// Disabled in desktop and failing.
        //[Fact]
        public void FlowchartInTryCatchBlock_FaultHandled()
        {
            TestFlowchart flowchart = new TestFlowchart();

            flowchart.AddStartLink(new TestThrow <Exception>()
            {
                ExpectedOutcome = Outcome.CaughtException()
            });

            TestTryCatch tryCatchFinally = new TestTryCatch
            {
                Try     = flowchart,
                Catches =
                {
                    new TestCatch <Exception>
                    {
                        Body = new TestWriteLine("ExceptionHandler", "Handled"),
                    }
                }
            };

            TestRuntime.RunAndValidateWorkflow(tryCatchFinally);
        }