コード例 #1
0
        public void FlowSwitchRequiresExpression()
        {
            TestFlowchart flowchart = new TestFlowchart();

            Act.Flowchart prod = flowchart.ProductActivity as Act.Flowchart;

            FlowStep            step1;
            FlowStep            step2;
            FlowSwitch <object> flowSwitch = new FlowSwitch <object>
            {
                Cases = { { 2, step2 = new FlowStep {
                                Action = new WriteLine{
                                    Text = "Dummy"
                                }
                            } } },
                Default = step1 = new FlowStep {
                    Action = new WriteLine {
                        Text = "Dummy"
                    }
                }
            };

            prod.StartNode = flowSwitch;
            prod.Nodes.Add(step1);
            prod.Nodes.Add(step2);

            List <string> errors = new List <string>();

            errors.Add(string.Format(ErrorStrings.FlowSwitchRequiresExpression, prod.DisplayName));

            Validate(flowchart, errors);
        }
コード例 #2
0
        public void ComplexScenario()
        {
            //TestFlowchart OM makes it difficult to construct such invalid flowchart, hence using product and wrapping it in TestFlowchart
            TestFlowchart flowchart = new TestFlowchart();

            Act.Flowchart prod = flowchart.ProductActivity as Act.Flowchart;

            FlowStep            A = new FlowStep();
            FlowSwitch <object> B = new FlowSwitch <object>();
            FlowStep            C = new FlowStep()
            {
                Action = new WriteLine {
                    Text = "Dummy"
                }
            };
            FlowDecision D = new FlowDecision();

            //A->B->C->D, StartNode = B, Nodes = {A, A, A}
            A.Next    = B;
            B.Default = C;
            C.Next    = D;

            prod.StartNode = B;

            prod.Nodes.Add(A);
            prod.Nodes.Add(A);
            prod.Nodes.Add(A);

            List <string> errors = new List <string>();

            errors.Add(string.Format(ErrorStrings.FlowSwitchRequiresExpression, prod.DisplayName));
            errors.Add(string.Format(ErrorStrings.FlowDecisionRequiresCondition, prod.DisplayName));

            Validate(flowchart, errors);
        }
コード例 #3
0
        public void FlowchartInitializerSyntax_Sequence()
        {
            Test.Common.TestObjects.CustomActivities.WriteLine writeLine1 = new Test.Common.TestObjects.CustomActivities.WriteLine
            {
                Message = new InArgument <string>("Hello1")
            };
            Test.Common.TestObjects.CustomActivities.WriteLine writeLine2 = new Test.Common.TestObjects.CustomActivities.WriteLine
            {
                Message = new InArgument <string>("Hello2")
            };
            Test.Common.TestObjects.CustomActivities.WriteLine writeLine3 = new Test.Common.TestObjects.CustomActivities.WriteLine
            {
                Message = new InArgument <string>("Hello3")
            };

            FlowStep flowStep1 = new FlowStep {
                Action = writeLine1
            };
            FlowStep flowStep2 = new FlowStep {
                Action = writeLine2, Next = flowStep1
            };
            FlowStep flowStep3 = new FlowStep {
                Action = writeLine3, Next = flowStep2
            };

            CoreWf.Statements.Flowchart flowchart = new CoreWf.Statements.Flowchart
            {
                Nodes =
                {
                    flowStep1, flowStep2, flowStep3
                },
                StartNode = flowStep3
            };

            AutoResetEvent are = new AutoResetEvent(false);

            WorkflowApplication application = new WorkflowApplication(flowchart)
            {
                Completed = delegate(WorkflowApplicationCompletedEventArgs e) { are.Set(); }
            };

            application.Run();

            are.WaitOne();
        }
コード例 #4
0
        public void FlowDecisionConditionMustBeSet()
        {
            TestFlowchart flowchart = new TestFlowchart();

            Act.Flowchart prod = flowchart.ProductActivity as Act.Flowchart;

            FlowStep     step;
            FlowDecision decision = new FlowDecision {
                True = step = new FlowStep {
                    Action = new WriteLine {
                        Text = "Dummy"
                    }
                }
            };

            prod.StartNode = decision;
            prod.Nodes.Add(step);

            List <string> errors = new List <string>();

            errors.Add(string.Format(ErrorStrings.FlowDecisionRequiresCondition, prod.DisplayName));

            Validate(flowchart, errors);
        }