Beispiel #1
0
        public async Task Pipeline_Overall_Result_Subject_Equals_Last_Changed_Subject()
        {
            var pipelineNode = new PipelineNode <TestObjectA>();

            var node1 = new SimpleTestNodeA1();
            var node2 = new SubjectChangingNode1();
            var node3 = new SimpleTestNodeA2();
            var node4 = new SubjectChangingNode1();

            pipelineNode.AddChild(node1);
            pipelineNode.AddChild(node2);
            pipelineNode.AddChild(node3);
            pipelineNode.AddChild(node4);

            var        testObject = new TestObjectA();
            NodeResult result     = await pipelineNode.ExecuteAsync(testObject);

            pipelineNode.Status.Should().Be(NodeRunStatus.Completed);

            var childResults = result.ChildResults.ToList();

            result.Subject.Should().NotBeSameAs(testObject);
            result.Subject.Should().NotBeSameAs(childResults[1].Subject);
            result.Subject.Should().NotBeSameAs(childResults[2].Subject);
            result.Subject.Should().BeSameAs(childResults[3].Subject);
        }
Beispiel #2
0
        public async void Parent_Pipeline_Cancels_Execution_When_Child_Pipeline_Node_Cancelled()
        {
            var testNode1 = new SimpleTestNodeA1();
            var testNode2 = new SimpleTestNodeA1(true, false, true);
            var testNode3 = new SimpleTestNodeA2();

            var innerPipelineNode = new PipelineNode <TestObjectA>();

            innerPipelineNode.AddChild(testNode1);
            innerPipelineNode.AddChild(testNode2);

            var pipelineNode = new PipelineNode <TestObjectA>();

            pipelineNode.AddChild(innerPipelineNode);
            pipelineNode.AddChild(testNode3);

            var testObject = new TestObjectA();

            NodeResult result = await pipelineNode.ExecuteAsync(testObject);

            result.Status.ShouldEqual(NodeResultStatus.Succeeded);

            innerPipelineNode.Status.ShouldEqual(NodeRunStatus.Completed);
            testNode1.Status.ShouldEqual(NodeRunStatus.Completed);
            testNode2.Status.ShouldEqual(NodeRunStatus.NotRun);
            pipelineNode.Status.ShouldEqual(NodeRunStatus.Completed);
            testNode3.Status.ShouldEqual(NodeRunStatus.NotRun);
        }
Beispiel #3
0
        public async void When_Cancelling_Pipeline_At_First_Node_Then_Status_Is_NotRun()
        {
            var pipelineNode = new PipelineNode <TestObjectA>();

            var testNode1 = new SimpleTestNodeA1(true, false, true);
            var testNode2 = new SimpleTestNodeA2();

            pipelineNode.AddChild(testNode1);
            pipelineNode.AddChild(testNode2);

            var testObject = new TestObjectA();

            NodeResult result = await pipelineNode.ExecuteAsync(testObject);

            result.Status.ShouldEqual(NodeResultStatus.NotRun);
            pipelineNode.Status.ShouldEqual(NodeRunStatus.Completed);

            testNode1.Status.ShouldEqual(NodeRunStatus.NotRun);
            testNode2.Status.ShouldEqual(NodeRunStatus.NotRun);
        }
        public async void Group_Overall_Result_Subject_Equals_Changed_Subject()
        {
            var groupNode = new GroupNode <TestObjectA>();

            var node1 = new SimpleTestNodeA1();
            var node2 = new SubjectChangingNode1();
            var node3 = new SimpleTestNodeA2();

            groupNode.AddChild(node1);
            groupNode.AddChild(node2);
            groupNode.AddChild(node3);

            var        testObject = new TestObjectA();
            NodeResult result     = await groupNode.ExecuteAsync(testObject);

            groupNode.Status.ShouldEqual(NodeRunStatus.Completed);

            var childResults = result.ChildResults.ToList();

            result.Subject.ShouldNotBeSameAs(testObject);
            result.Subject.ShouldBeSameAs(childResults[1].Subject);
        }
        public async Task FirstMatch_Node_Fails_When_Selected_Node_Faults()
        {
            var matchNode = new FirstMatchNode <TestObjectA>();

            var firstNode = new FaultingTestNodeA();

            matchNode.AddChild(firstNode);

            var secondNode = new SimpleTestNodeA2();

            matchNode.AddChild(secondNode);

            var        testObject = new TestObjectA();
            NodeResult result     = await matchNode.ExecuteAsync(testObject);

            matchNode.Status.Should().Be(NodeRunStatus.Completed);
            firstNode.Status.Should().Be(NodeRunStatus.Faulted);
            secondNode.Status.Should().Be(NodeRunStatus.NotRun);
            result.Status.Should().Be(NodeResultStatus.Failed);

            testObject.TestValueString.Should().Be("Faulted");
            testObject.TestValueInt.Should().Be(0);
        }
        public async Task Successful_FirstMatch_Node_Runs_Second_Node_When_First_Not_Matched()
        {
            var matchNode = new FirstMatchNode <TestObjectA>();

            var firstNode = new SimpleTestNodeA1(false);

            matchNode.AddChild(firstNode);

            var secondNode = new SimpleTestNodeA2();

            matchNode.AddChild(secondNode);

            var        testObject = new TestObjectA();
            NodeResult result     = await matchNode.ExecuteAsync(testObject);

            matchNode.Status.Should().Be(NodeRunStatus.Completed);
            firstNode.Status.Should().Be(NodeRunStatus.NotRun);
            secondNode.Status.Should().Be(NodeRunStatus.Completed);
            result.Status.Should().Be(NodeResultStatus.Succeeded);

            testObject.TestValueString.Should().BeNull();
            testObject.TestValueInt.Should().Be(100);
        }
Beispiel #7
0
        public async Task When_Cancelling_Pipeline_At_Later_Node_Then_Status_Is_Success()
        {
            var pipelineNode = new PipelineNode <TestObjectA>();

            var testNode1 = new SimpleTestNodeA1();
            var testNode2 = new SimpleTestNodeA1(true, false, true);
            var testNode3 = new SimpleTestNodeA2();

            pipelineNode.AddChild(testNode1);
            pipelineNode.AddChild(testNode2);
            pipelineNode.AddChild(testNode3);

            var testObject = new TestObjectA();

            NodeResult result = await pipelineNode.ExecuteAsync(testObject);

            result.Status.Should().Be(NodeResultStatus.Succeeded);
            pipelineNode.Status.Should().Be(NodeRunStatus.Completed);

            testNode1.Status.Should().Be(NodeRunStatus.Completed);
            testNode2.Status.Should().Be(NodeRunStatus.NotRun);
            testNode3.Status.Should().Be(NodeRunStatus.NotRun);
        }
        public async void Pipeline_Node_Results_Following_Subject_Change_Node_Return_Changed_Subject()
        {
            var pipelineNode = new PipelineNode <TestObjectA>();

            var node1 = new SimpleTestNodeA1();
            var node2 = new SubjectChangingNode1();
            var node3 = new SimpleTestNodeA2();

            pipelineNode.AddChild(node1);
            pipelineNode.AddChild(node2);
            pipelineNode.AddChild(node3);

            var        testObject = new TestObjectA();
            NodeResult result     = await pipelineNode.ExecuteAsync(testObject);

            pipelineNode.Status.ShouldEqual(NodeRunStatus.Completed);

            var childResults = result.ChildResults.ToList();

            childResults[0].Subject.ShouldBeSameAs(testObject);
            childResults[1].Subject.ShouldNotBeSameAs(testObject);
            childResults[2].Subject.ShouldNotBeSameAs(testObject);
            childResults[1].Subject.ShouldEqual(childResults[2].Subject);
        }