示例#1
0
        public void Should_SuccessFourSteps_FailedFourthStep_RunAction()
        {
            var expectedMessages = new BlockingCollection <string>()
            {
                "Success step: 1",
                "Success step: 2",
                "Failed step: 4",
                "Success step: 3",
                "Success step: 5",
                "Run action"
            };

            BlockingCollection <string> actualMessages = new BlockingCollection <string>();

            var fifthStep = new TestStep(actualMessages)
            {
                StepId = 5
            };
            var fourthStep = new TestStep(actualMessages, new[] { fifthStep })
            {
                StepId = 4, IsError = true
            };
            var thirdStep = new TestStep(actualMessages, new[] { fifthStep })
            {
                StepId = 3
            };
            var secondStep = new TestStep(actualMessages, new[] { fourthStep })
            {
                StepId = 2
            };
            var firstStep = new TestStep(actualMessages, new[] { secondStep, thirdStep })
            {
                StepId = 1
            };

            List <TestStep> steps = new List <TestStep>
            {
                firstStep,
                secondStep,
                thirdStep,
                fourthStep,
                fifthStep
            };

            var action   = new TestAction(actualMessages);
            var workflow = new TestWorkflow(actualMessages, steps[0], action);
            var result   = workflow.Start();

            Assert.IsTrue(result);
            CollectionAssert.AreEqual(expectedMessages, actualMessages);
        }
示例#2
0
        public void Should_ReturnFalse_When_LoopingSteps()
        {
            var expectedMessages = new BlockingCollection <string>()
            {
                "Success step: 1",
                "Success step: 2",
                "Success step: 3",
                "Success step: 4",
                "Success step: 5",
                "Success step: 6",
                "Success step: 7",
                "Success step: 8",
                "Success step: 9"
            };

            BlockingCollection <string> actualMessages = new BlockingCollection <string>();

            TestStep ninthStep = new TestStep(actualMessages)
            {
                StepId = 9
            };
            var eighthStep = new TestStep(actualMessages, new[] { ninthStep })
            {
                StepId = 8
            };
            var seventhStep = new TestStep(actualMessages, new[] { eighthStep })
            {
                StepId = 7
            };
            var sixthStep = new TestStep(actualMessages, new[] { seventhStep })
            {
                StepId = 6
            };
            var fifthStep = new TestStep(actualMessages, new[] { sixthStep })
            {
                StepId = 5
            };
            var fourthStep = new TestStep(actualMessages, new[] { fifthStep })
            {
                StepId = 4
            };
            var thirdStep = new TestStep(actualMessages, new[] { fourthStep })
            {
                StepId = 3
            };
            var secondStep = new TestStep(actualMessages, new[] { thirdStep })
            {
                StepId = 2
            };
            var firstStep = new TestStep(actualMessages, new[] { secondStep })
            {
                StepId = 1
            };

            ninthStep.NextSteps.Add(fifthStep);

            List <TestStep> steps = new List <TestStep>
            {
                firstStep,
                secondStep,
                thirdStep,
                fourthStep,
                fifthStep,
                sixthStep,
                seventhStep,
                eighthStep,
                ninthStep
            };

            var action   = new TestAction(actualMessages);
            var workflow = new TestWorkflow(actualMessages, steps[0], action);
            var result   = workflow.Start();

            Assert.IsFalse(result);
            CollectionAssert.AreEqual(expectedMessages, actualMessages);
        }