Example #1
0
        public void TestPvmWaitState()
        {
            IPvmProcessDefinition processDefinition = new ProcessDefinitionBuilder()
                                                      .CreateActivity("a")
                                                      .Initial()
                                                      .Behavior(new WaitState())
                                                      .Transition("b")
                                                      .EndActivity()
                                                      .CreateActivity("b")
                                                      .Behavior(new WaitState())
                                                      .Transition("c")
                                                      .EndActivity()
                                                      .CreateActivity("c")
                                                      .Behavior(new WaitState())
                                                      .EndActivity()
                                                      .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IPvmExecution activityInstance = processInstance.FindExecution("a");

            Assert.NotNull(activityInstance);

            activityInstance.Signal(null, null);

            activityInstance = processInstance.FindExecution("b");
            Assert.NotNull(activityInstance);

            activityInstance.Signal(null, null);

            activityInstance = processInstance.FindExecution("c");
            Assert.NotNull(activityInstance);
        }
        public virtual void TestWaitStateScope()
        {
            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .Transition("scopedWait")
                .EndActivity()
                .CreateActivity("scopedWait")
                .Scope()
                .Behavior(new WaitState())
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IPvmExecution execution = processInstance.FindExecution("scopedWait");

            Assert.NotNull(execution);

            execution.Signal(null, null);

            Assert.AreEqual(new List <string>(), processInstance.FindActiveActivityIds());
            Assert.True(processInstance.IsEnded);
        }
Example #3
0
        public void TestPvmDecision()
        {
            IPvmProcessDefinition processDefinition = new ProcessDefinitionBuilder()
                                                      .CreateActivity("start")
                                                      .Initial()
                                                      .Behavior(new Automatic())
                                                      .Transition("checkCredit")
                                                      .EndActivity()
                                                      .CreateActivity("checkCredit")
                                                      .Behavior(new Decision())
                                                      .Transition("askDaughterOut", "wow")
                                                      .Transition("takeToGolf", "nice")
                                                      .Transition("ignore", "default")
                                                      .EndActivity()
                                                      .CreateActivity("takeToGolf")
                                                      .Behavior(new WaitState())
                                                      .EndActivity()
                                                      .CreateActivity("askDaughterOut")
                                                      .Behavior(new WaitState())
                                                      .EndActivity()
                                                      .CreateActivity("ignore")
                                                      .Behavior(new WaitState())
                                                      .EndActivity()
                                                      .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.SetVariable("creditRating", "Aaa-");
            processInstance.Start();
            Assert.NotNull(processInstance.FindExecution("takeToGolf"));

            processInstance = processDefinition.CreateProcessInstance();
            processInstance.SetVariable("creditRating", "AAA+");
            processInstance.Start();
            Assert.NotNull(processInstance.FindExecution("askDaughterOut"));

            processInstance = processDefinition.CreateProcessInstance();
            processInstance.SetVariable("creditRating", "bb-");
            processInstance.Start();
            Assert.NotNull(processInstance.FindExecution("ignore"));
        }
        public virtual void TestScopeActivity()
        {
            var verifier = new ActivityInstanceVerification();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("one")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("two")
                .EndActivity()
                .CreateActivity("two")
                .Scope()
                .Behavior(new WaitState())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("three")
                .EndActivity()
                .CreateActivity("three")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            IPvmExecution childExecution           = processInstance.FindExecution("two");
            var           parentActivityInstanceId = ((ExecutionImpl)childExecution).ParentActivityInstanceId;

            Assert.AreEqual(((ExecutionImpl)processInstance).Id, parentActivityInstanceId);

            childExecution.Signal(null, null);

            verifier.AssertStartInstanceCount(1, "one");
            verifier.AssertStartInstanceCount(1, "two");
            verifier.AssertProcessInstanceParent("two", processInstance);
            verifier.AssertStartInstanceCount(1, "three");
        }
        public virtual void TestMultipleConcurrentEndsInsideEmbeddedSubProcessWithWaitState()
        {
            var verifier = new ActivityInstanceVerification();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("embeddedsubprocess")
                .EndActivity()
                .CreateActivity("embeddedsubprocess")
                .Scope()
                .Behavior(new EmbeddedSubProcess())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .CreateActivity("startInside")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("fork")
                .EndActivity()
                .CreateActivity("fork")
                .Behavior(new ParallelGateway())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("endInside1")
                .Transition("Wait")
                .Transition("endInside3")
                .EndActivity()
                .CreateActivity("endInside1")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .CreateActivity("Wait")
                .Behavior(new WaitState())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("endInside2")
                .EndActivity()
                .CreateActivity("endInside2")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .CreateActivity("endInside3")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .Transition("end")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.IsFalse(processInstance.IsEnded);
            IPvmExecution execution = processInstance.FindExecution("Wait");

            execution.Signal(null, null);

            Assert.True(processInstance.IsEnded);

            verifier.AssertStartInstanceCount(1, "start");
            verifier.AssertProcessInstanceParent("start", processInstance);

            verifier.AssertStartInstanceCount(1, "embeddedsubprocess");
            verifier.AssertProcessInstanceParent("embeddedsubprocess", processInstance);

            verifier.AssertStartInstanceCount(1, "startInside");
            verifier.AssertParent("startInside", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "fork");
            verifier.AssertParent("fork", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "Wait");
            verifier.AssertParent("Wait", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "endInside1");
            verifier.AssertParent("endInside1", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "endInside2");
            verifier.AssertParent("endInside2", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "endInside3");
            verifier.AssertParent("endInside3", "embeddedsubprocess");

            verifier.AssertStartInstanceCount(1, "end");
            verifier.AssertProcessInstanceParent("end", processInstance);
        }