示例#1
0
        public void FlowSwitchHavingCaseWithNullKeyEvaluateNull()
        {
            TestFlowchart flowchart = new TestFlowchart();

            Variable <Complex> complexVar = VariableHelper.CreateInitialized <Complex>("complexVar", (Complex)null);

            flowchart.Variables.Add(complexVar);

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

            cases.Add(new Complex(0, 0), new TestWriteLine("One", "One"));
            cases.Add(new Complex(1, 0), new TestWriteLine("Two", "Two"));
            cases.Add(new Complex(2, 0), new TestWriteLine("Three", "Three"));

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

            TestFlowSwitch <Complex> flowSwitch = flowchart.AddSwitchLink <Complex>(new TestWriteLine("Start", "Flowchart started"), cases, hints, e => complexVar.Get(e)) as TestFlowSwitch <Complex>;

            ((FlowSwitch <Complex>)flowSwitch.GetProductElement()).Cases.Add(null, new FlowStep {
                Action = new BlockingActivity("Blocking")
            });

            using (TestWorkflowRuntime runtime = TestRuntime.CreateTestWorkflowRuntime(flowchart))
            {
                runtime.ExecuteWorkflow();
                runtime.WaitForActivityStatusChange("Blocking", TestActivityInstanceState.Executing);
                runtime.ResumeBookMark("Blocking", null);

                runtime.WaitForCompletion(false);
            }
        }
示例#2
0
        public void FlowSwitchWithExpressionNull()
        {
            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 wDefault   = new TestWriteLine("wDefault", "Executing wDefault");

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

            cases.Add("One", w1);
            cases.Add("Two", w2);

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

            hints.Add(-1);

            TestFlowSwitch <object> fSwitch = (TestFlowSwitch <object>)flowchart1.AddSwitchLink <object>(start1, cases, hints, (object)null, wDefault);

            ((FlowSwitch <object>)fSwitch.GetProductElement()).Expression = null; // I had to use the product to set a null value to Expression

            TestRuntime.ValidateInstantiationException(flowchart1, string.Format(ErrorStrings.FlowSwitchRequiresExpression, flowchart1.DisplayName));
        }