コード例 #1
0
        public void TerminateActivityInFlowchart()
        {
            s_exceptionType     = typeof(TAC.ApplicationException);
            s_exceptionMsg      = "Flowchart terminating";
            s_terminationReason = "Bad Flowchart!";

            TestSequence baseSeq = new TestSequence("BaseSequence")
            {
                Activities =
                {
                    new TestWriteLine("Base")
                    {
                        Message     = "Boring Base",
                        HintMessage = "Boring Base",
                    }
                }
            };

            TestSequence trueBranch = new TestSequence("TrueSequence")
            {
                Activities =
                {
                    new TestWriteLine("TrueWriteLine")
                    {
                        Message     = "I only know the truth!",
                        HintMessage = "I only know the truth!",
                    },
                    new TestTerminateWorkflow()
                    {
                        ExceptionExpression = ((env) => new TAC.ApplicationException("Flowchart terminating")),
                        Reason = s_terminationReason
                    }
                }
            };

            TestSequence falseBranch = new TestSequence("FalseSequence")
            {
                Activities =
                {
                    new TestWriteLine("FalseWriteLine")
                    {
                        Message     = "I'm a liar",
                        HintMessage = "Bug if gets here",
                    }
                }
            };

            TestFlowchart       flowchart    = new TestFlowchart("FlowChart");
            TestFlowConditional flowDecision = new TestFlowConditional
            {
                Condition = true
            };

            flowchart.AddConditionalLink(baseSeq, flowDecision, trueBranch, falseBranch);
            RunTestWithWorkflowRuntime(flowchart);
        }
コード例 #2
0
ファイル: Loops.cs プロジェクト: sunxiaotianmg/CoreWF
        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);
        }
コード例 #3
0
        public void DecisionWithNoPinConnected()
        {
            TestFlowchart flowchart = new TestFlowchart();

            TestFlowConditional decision = new TestFlowConditional();

            decision.Condition = true;
            flowchart.AddConditionalLink(new TestWriteLine("Start", "Flowchart started"), decision);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #4
0
ファイル: ObjectModel.cs プロジェクト: sunxiaotianmg/CoreWF
        public void FlowConditionalWithBothTrueAndFalseActionNull()
        {
            TestFlowConditional conditional = new TestFlowConditional
            {
                Condition = false
            };
            TestFlowchart flowchart = new TestFlowchart();

            flowchart.AddConditionalLink(null, conditional);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #5
0
        public void ConditionExpressionSetToNull()
        {
            TestFlowConditional conditional = new TestFlowConditional();

            conditional.ProductFlowConditional.Condition = null;

            TestFlowchart flowchart = new TestFlowchart();

            flowchart.AddConditionalLink(null, conditional, new TestWriteLine("True", "True"), new TestWriteLine("False", "False"));

            TestRuntime.ValidateInstantiationException(flowchart, string.Format(ErrorStrings.FlowDecisionRequiresCondition, flowchart.DisplayName));
        }
コード例 #6
0
        public void TrueFalsePinsInOrJoin()
        {
            TestFlowchart flowchart = new TestFlowchart("Flow1");

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

            TestFlowConditional flowDecision = new TestFlowConditional();

            flowDecision.Condition = true;

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

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #7
0
        public void DecisionFalsePinConnectedConditionEvaluationTrue()
        {
            TestFlowchart flowchart = new TestFlowchart("Flow1");

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

            TestFlowConditional flowDecision = new TestFlowConditional();

            flowDecision.Condition = true;

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

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #8
0
ファイル: ObjectModel.cs プロジェクト: sunxiaotianmg/CoreWF
        public void FlowStepConnectedToFlowDecision()
        {
            TestFlowchart flowchart = new TestFlowchart();

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

            TestFlowConditional conditional = new TestFlowConditional()
            {
                Condition = true
            };

            flowchart.AddConditionalLink(w1, conditional, new TestWriteLine("True", "True"), (TestActivity)null);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #9
0
        public void DecisionWithConditionSetToExpressionActivity()
        {
            TestExpressionEvaluator <bool> myExpression = new TestExpressionEvaluator <bool>(true);

            TestFlowConditional flowConditinoal = new TestFlowConditional
            {
                ConditionValueExpression = (TestActivity)myExpression
            };
            TestFlowchart flowchart = new TestFlowchart();

            flowchart.AddConditionalLink(new TestWriteLine("Start", "FLowchart started"),
                                         flowConditinoal,
                                         new TestWriteLine("True Action", "True Action"),
                                         new TestWriteLine("False Action", "False Action"));

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #10
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)
            {
                Condition = false
            };

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

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #11
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);
        }
コード例 #12
0
        public void ConditionExpressionOnExistingVariable()
        {
            TestFlowchart flowchart = new TestFlowchart();

            Variable <bool> flag = VariableHelper.CreateInitialized <bool>(true);

            flag.Name = "flag";
            flowchart.Variables.Add(flag);

            TestFlowConditional decision = new TestFlowConditional {
                ConditionExpression = e => flag.Get(e)
            };

            flowchart.AddConditionalLink(new TestWriteLine("Start", "Start"), decision, new TestWriteLine("True", "True"), new TestWriteLine("false", "false"));

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #13
0
ファイル: ObjectModel.cs プロジェクト: jimitndiaye/corewf
        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);
        }
コード例 #14
0
        public void FlowchartWithOnlyFlowConditionalWithoutStartEvent()
        {
            TestFlowchart flowchart = new TestFlowchart();

            Variable <bool> flag = VariableHelper.CreateInitialized <bool>(true);

            flag.Name = "flag";
            flowchart.Variables.Add(flag);

            TestFlowConditional decision = new TestFlowConditional {
                ConditionExpression = env => flag.Get(env)
            };

            flowchart.AddConditionalLink(null, decision, new TestWriteLine("True", "True"), new TestWriteLine("False", "False"));

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #15
0
ファイル: ObjectModel.cs プロジェクト: jimitndiaye/corewf
        public void FlowDecisionAsStartElement()
        {
            TestFlowchart flowchart1 = new TestFlowchart("flowChart1");

            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);

            TestRuntime.RunAndValidateWorkflow(flowchart1);
        }
コード例 #16
0
ファイル: ObjectModel.cs プロジェクト: sunxiaotianmg/CoreWF
        public void ConnectFromFlowconditionalBothTrueAndFalseToDifferentFlowconditional()
        {
            TestFlowchart flowchart = new TestFlowchart();

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

            flowchart.Variables.Add(counter);

            TestAssign <int> assign = new TestAssign <int>("assign")
            {
                ValueExpression = (e => counter.Get(e) + 1),
                ToVariable      = counter
            };

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

            for (int i = 0; i < 4; i++)
            {
                hints.Add(HintTrueFalse.False);
            }
            hints.Add(HintTrueFalse.True);
            TestFlowConditional conditional1 = new TestFlowConditional(hints.ToArray())
            {
                ConditionExpression = (e => counter.Get(e) == 5)
            };

            TestFlowConditional conditional2 = new TestFlowConditional
            {
                Condition = true
            };

            TestFlowConditional conditional3 = new TestFlowConditional
            {
                Condition = true
            };

            flowchart.AddLink(new TestWriteLine("Start", "Flowchart Started"), assign);
            flowchart.AddConditionalLink(assign, conditional1, conditional3, conditional2);
            flowchart.AddConditionalLink(null, conditional2, assign, (TestActivity)null);
            flowchart.AddConditionalLink(null, conditional3, new TestWriteLine("End", "The End"), (TestActivity)null);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #17
0
ファイル: ObjectModel.cs プロジェクト: jimitndiaye/corewf
        public void AddSameElementToParentAndChild()
        {
            TestFlowchart   flowchart1 = new TestFlowchart("flowChart1");
            TestFlowchart   flowchart2 = new TestFlowchart("flowChart2");
            TestWriteLine   w1         = new TestWriteLine("W1", "Executing W1");
            TestFlowElement fStep      = new TestFlowStep(w1);

            flowchart2.Elements.Add(fStep);

            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, fStep, flowchart2);

            TestRuntime.ValidateInstantiationException(flowchart1, string.Format(ErrorStrings.FlowNodeCannotBeShared, flowchart1.DisplayName, flowchart2.DisplayName));
        }
コード例 #18
0
        public void DecisionTrueEvaluation()
        {
            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();

            flowDecision.ConditionExpression = ((env) => (counter.Get(env) == 3));

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

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #19
0
ファイル: ObjectModel.cs プロジェクト: jimitndiaye/corewf
        public void FlowDecisionWithTrueElementNullEvaluationTrue()
        {
            // This is a valid testcase and we don't expect error.
            TestFlowchart flowchart1 = new TestFlowchart("flowChart1");

            TestWriteLine w2True  = new TestWriteLine("True", "True will execute");
            TestWriteLine w2False = new TestWriteLine("False", "False wont execute");

            Variable <int> margin = new Variable <int> {
                Name = "margin", Default = 10
            };

            flowchart1.Variables.Add(margin);
            TestFlowConditional flowDecision = new TestFlowConditional((HintTrueFalse[])null); // null here means neither True or False will happen as the action is null

            flowDecision.ConditionExpression = (context => margin.Get(context) > 0);
            TestFlowElement tCond = flowchart1.AddConditionalLink(null, flowDecision, null, w2False);

            TestRuntime.RunAndValidateWorkflow(flowchart1);
        }
コード例 #20
0
        public void ExpressionSetToTrue()
        {
            TestFlowchart flowchart = new TestFlowchart("Flow1");

            Variable <bool> trueVar = new Variable <bool>("trueVar", true);

            flowchart.Variables.Add(trueVar);

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

            TestFlowConditional flowDecision = new TestFlowConditional();

            flowDecision.ConditionVariable = trueVar;

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

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #21
0
ファイル: ObjectModel.cs プロジェクト: jimitndiaye/corewf
        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);
        }
コード例 #22
0
ファイル: ObjectModel.cs プロジェクト: jimitndiaye/corewf
        public void ConnectFromFlowconditionalTrueToFlowconditional()
        {
            TestFlowchart flowchart = new TestFlowchart();

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

            TestFlowConditional conditional1 = new TestFlowConditional();

            conditional1.Condition = true;

            TestFlowConditional conditional2 = new TestFlowConditional();

            conditional2.Condition = true;

            flowchart.AddConditionalLink(w1, conditional1);
            flowchart.AddConditionalLink(null, conditional2, w2, (TestActivity)null);
            flowchart.AddConditionalLink(null, conditional1, conditional2, (TestActivity)null);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #23
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);
        }
コード例 #24
0
        public void UnloadFlowchartWhileExecutingFlowConditionalCondition()
        {
            TestFlowchart flowchart = new TestFlowchart();

            TestExpressionEvaluatorWithBody <bool> expression = new TestExpressionEvaluatorWithBody <bool>(true)
            {
                Body            = new TestBlockingActivity("Block"),
                WillBodyExecute = true
            };

            TestFlowConditional conditional = new TestFlowConditional(HintTrueFalse.True)
            {
                ConditionValueExpression = expression
            };

            flowchart.AddConditionalLink(new TestWriteLine("Start", "Flowchart started"),
                                         conditional,
                                         new TestWriteLine("True", "True Action"),
                                         new TestWriteLine("False", "False Action"));


            JsonFileInstanceStore.FileInstanceStore jsonStore = new JsonFileInstanceStore.FileInstanceStore(System.Environment.CurrentDirectory);

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

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

                //testWorkflowRuntime.PersistWorkflow();
                testWorkflowRuntime.UnloadWorkflow();

                testWorkflowRuntime.LoadWorkflow();

                testWorkflowRuntime.ResumeBookMark("Block", null);

                testWorkflowRuntime.WaitForCompletion(true);
            }
        }
コード例 #25
0
        public void CancelFlowchartWhileEvaluatingFlowConditionalCondition()
        {
            TestFlowchart flowchart = new TestFlowchart();

            TestBlockingActivity blocking = new TestBlockingActivity("Block", "Blocked")
            {
                ExpectedOutcome = Outcome.Canceled
            };

            TestExpressionEvaluatorWithBody <bool> expression = new TestExpressionEvaluatorWithBody <bool>(true)
            {
                Body            = blocking,
                WillBodyExecute = true
            };

            TestFlowConditional conditional = new TestFlowConditional
            {
                ConditionValueExpression = expression
            };

            flowchart.AddConditionalLink(new TestWriteLine("Start", "Flowchart started"),
                                         conditional,
                                         new TestWriteLine("True", "True Action"),
                                         new TestWriteLine("False", "False Action"));

            expression.ExpectedOutcome = Outcome.Canceled;
            flowchart.ExpectedOutcome  = Outcome.Canceled;

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

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

                testWorkflowRuntime.CancelWorkflow();

                testWorkflowRuntime.WaitForCanceled(true);
            }
        }
コード例 #26
0
ファイル: ObjectModel.cs プロジェクト: sunxiaotianmg/CoreWF
        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);
        }
コード例 #27
0
        /// <summary>
        /// Exception thrown during expression evaluation.
        /// </summary>
        /// This test is disabled in desktop and failing too.
        //[Fact]
        public void FaultWhileExpressionEvaluation()
        {
            const string  exceptionString = "I am a faulty little expression's exception";
            TestFlowchart flowchart       = new TestFlowchart("Flow1");

            TestExpressionEvaluatorWithBody <bool> faultyExpression = new TestExpressionEvaluatorWithBody <bool>
            {
                Body = new TestThrow <Exception>("Faulty Little Expression")
                {
                    ExceptionExpression = (context => new Exception(exceptionString))
                }
            };
            TestWriteLine writeLine1 = new TestWriteLine("WriteStatus", "I will execute");

            TestFlowConditional conditional = new TestFlowConditional()
            {
                ConditionValueExpression = faultyExpression
            };

            flowchart.AddConditionalLink(writeLine1, conditional, new TestWriteLine("True", "True"), new TestWriteLine("False", "False"));

            TestRuntime.RunAndValidateAbortedException(flowchart, typeof(Exception), new Dictionary <string, string>());
        }
コード例 #28
0
ファイル: ObjectModel.cs プロジェクト: sunxiaotianmg/CoreWF
        public void ConnectFromFlowconditionalFalseToFlowconditional()
        {
            TestFlowchart flowchart = new TestFlowchart();

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

            TestFlowConditional conditional1 = new TestFlowConditional(HintTrueFalse.False)
            {
                Condition = false
            };

            TestFlowConditional conditional2 = new TestFlowConditional
            {
                Condition = true
            };

            flowchart.AddConditionalLink(w1, conditional1);
            flowchart.AddConditionalLink(null, conditional1, (TestActivity)null, conditional2);
            flowchart.AddConditionalLink(null, conditional2, w2, (TestActivity)null);

            TestRuntime.RunAndValidateWorkflow(flowchart);
        }
コード例 #29
0
ファイル: Loops.cs プロジェクト: sunxiaotianmg/CoreWF
        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")
            {
                ValueExpression = (env => ((int)counter.Get(env)) + 1),
                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())
            {
                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);
        }
コード例 #30
0
ファイル: ObjectModel.cs プロジェクト: sunxiaotianmg/CoreWF
        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)
            {
                ConditionExpression = (context => margin.Get(context) > 0)
            };
            TestFlowElement tCond = flowchart1.AddConditionalLink(null, flowDecision, w2True, w2False);

            flowchart1.Elements.Add(tCond);

            TestRuntime.RunAndValidateWorkflow(flowchart1);
        }