コード例 #1
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);
        }
コード例 #2
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();
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
0
        /// <summary>
        /// Exception thrown during expression evaluation of switch.
        /// Exception thrown during expression evaluation of switch
        /// </summary>
        /// This test is disabled in desktop and failing too.
        //[Fact]
        public void FaultWhileSwitchExpressionEvaluation()
        {
            TestFlowchart flowchart = new TestFlowchart();

            TestExpressionEvaluatorWithBody <object> faultExp = new TestExpressionEvaluatorWithBody <object>
            {
                Body = new TestThrow <InvalidProgramException>()
            };

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

            cases.Add("One", new TestWriteLine("One", "One"));
            cases.Add("Two", new TestWriteLine("Two", "Two"));

            flowchart.AddSwitchLink(new TestWriteLine("Start", "Start"), cases, new List <int>()
            {
                -1
            }, faultExp, new TestWriteLine("Default", "Default"));

            TestRuntime.RunAndValidateAbortedException(flowchart, typeof(InvalidProgramException), null);
        }
コード例 #5
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);
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
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>());
        }