예제 #1
0
        /// <summary>
        ///                  +----------------------------+
        ///                  v                            |
        /// +-------+   +------+   +-----+   +-----+    +-------+
        /// | start |-->| loop |-->| one |-->| two |--> | three |
        /// +-------+   +------+   +-----+   +-----+    +-------+
        ///                  |
        ///                  |   +-----+
        ///                  +-->| end |
        ///                      +-----+
        /// </summary>
        public virtual void testWhileLoop()
        {
            ActivityInstanceVerification verifier           = new ActivityInstanceVerification();
            TransitionInstanceVerifyer   transitionVerifier = new TransitionInstanceVerifyer();

            PvmProcessDefinition processDefinition = (new ProcessDefinitionBuilder()).createActivity("start").initial().behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).startTransition("loop").executionListener([email protected]_Fields.EVENTNAME_TAKE, transitionVerifier).endTransition().endActivity().createActivity("loop").behavior(new While("count", 0, 10)).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).startTransition("one", "more").executionListener([email protected]_Fields.EVENTNAME_TAKE, transitionVerifier).endTransition().startTransition("end", "done").executionListener([email protected]_Fields.EVENTNAME_TAKE, transitionVerifier).endTransition().endActivity().createActivity("one").behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("two").endActivity().createActivity("two").behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("three").endActivity().createActivity("three").behavior(new Automatic()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).transition("loop").endActivity().createActivity("end").behavior(new End()).executionListener([email protected]_Fields.EVENTNAME_START, verifier).executionListener([email protected]_Fields.EVENTNAME_END, verifier).endActivity().buildProcessDefinition();

            PvmProcessInstance processInstance = processDefinition.createProcessInstance();

            processInstance.start();

            assertEquals(new List <string>(), processInstance.findActiveActivityIds());
            assertTrue(processInstance.Ended);

            verifier.assertStartInstanceCount(1, "start");
            verifier.assertProcessInstanceParent("start", processInstance);

            verifier.assertStartInstanceCount(11, "loop");
            verifier.assertProcessInstanceParent("loop", processInstance);

            verifier.assertStartInstanceCount(10, "one");
            verifier.assertProcessInstanceParent("one", processInstance);

            verifier.assertStartInstanceCount(10, "two");
            verifier.assertProcessInstanceParent("two", processInstance);

            verifier.assertStartInstanceCount(10, "three");
            verifier.assertProcessInstanceParent("three", processInstance);

            verifier.assertStartInstanceCount(1, "end");
            verifier.assertProcessInstanceParent("end", processInstance);
        }
예제 #2
0
        public virtual void TestWhileLoop()
        {
            var verifier           = new ActivityInstanceVerification();
            var transitionVerifier = new TransitionInstanceVerifyer();

            IPvmProcessDefinition processDefinition =
                new ProcessDefinitionBuilder().CreateActivity("start")
                .Initial()
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .StartTransition("loop")
                .ExecutionListener(ExecutionListenerFields.EventNameTake, transitionVerifier)
                .EndTransition()
                .EndActivity()
                .CreateActivity("loop")
                .Behavior(new While("Count", 0, 10))
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .StartTransition("one", "more")
                .ExecutionListener(ExecutionListenerFields.EventNameTake, transitionVerifier)
                .EndTransition()
                .StartTransition("end", "done")
                .ExecutionListener(ExecutionListenerFields.EventNameTake, transitionVerifier)
                .EndTransition()
                .EndActivity()
                .CreateActivity("one")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("two")
                .EndActivity()
                .CreateActivity("two")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("three")
                .EndActivity()
                .CreateActivity("three")
                .Behavior(new Automatic())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .Transition("loop")
                .EndActivity()
                .CreateActivity("end")
                .Behavior(new End())
                .ExecutionListener(ExecutionListenerFields.EventNameStart, verifier)
                .ExecutionListener(ExecutionListenerFields.EventNameEnd, verifier)
                .EndActivity()
                .BuildProcessDefinition();

            IPvmProcessInstance processInstance = processDefinition.CreateProcessInstance();

            processInstance.Start();

            Assert.AreEqual(new List <string>(), processInstance.FindActiveActivityIds());
            Assert.True(processInstance.IsEnded);

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

            verifier.AssertStartInstanceCount(11, "loop");
            verifier.AssertProcessInstanceParent("loop", processInstance);

            verifier.AssertStartInstanceCount(10, "one");
            verifier.AssertProcessInstanceParent("one", processInstance);

            verifier.AssertStartInstanceCount(10, "two");
            verifier.AssertProcessInstanceParent("two", processInstance);

            verifier.AssertStartInstanceCount(10, "three");
            verifier.AssertProcessInstanceParent("three", processInstance);

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