public void TransformPhaseGetsAllDocuments()
            {
                // Given
                TestDocument a1 = new TestDocument("a1");
                TestDocument b1 = new TestDocument("b1");
                TestDocument b2 = new TestDocument("b2");
                TestDocument c1 = new TestDocument("c1");
                TestDocument d1 = new TestDocument("d1");
                TestDocument d2 = new TestDocument("d2");
                ConcurrentDictionary <string, PhaseResult[]> phaseResults =
                    new ConcurrentDictionary <string, PhaseResult[]>(StringComparer.OrdinalIgnoreCase);
                IPipelineCollection pipelines = new TestPipelineCollection();
                PipelinePhase       phaseA    =
                    GetPipelineAndPhase("A", Phase.Transform, pipelines, phaseResults, new[] { a1 });
                PipelinePhase phaseB =
                    GetPipelineAndPhase("B", Phase.Transform, pipelines, phaseResults, new[] { b1, b2 }, phaseA);
                PipelinePhase phaseC =
                    GetPipelineAndPhase("C", Phase.Transform, pipelines, phaseResults, new[] { c1 }, phaseB);
                PipelinePhase phaseD =
                    GetPipelineAndPhase("D", Phase.Transform, pipelines, phaseResults, new[] { d1, d2 });
                ProcessPhaseOutputs documentCollection = new ProcessPhaseOutputs(phaseResults, phaseC, pipelines);

                // When
                IDocument[] result = documentCollection.ToArray();

                // Then
                result.ShouldBe(new[] { a1, b1, b2, c1, d1, d2 }, true);
            }
Exemplo n.º 2
0
            public void ExcludeFromDeploymentDuringOutput()
            {
                // Given
                TestDocument a1 = new TestDocument("a1");
                TestDocument b1 = new TestDocument("b1");
                TestDocument b2 = new TestDocument("b2");
                TestDocument c1 = new TestDocument("c1");
                TestDocument d1 = new TestDocument("d1");
                TestDocument d2 = new TestDocument("d2");
                ConcurrentDictionary <string, PhaseResult[]> phaseResults =
                    new ConcurrentDictionary <string, PhaseResult[]>(StringComparer.OrdinalIgnoreCase);
                IPipelineCollection pipelines = new TestPipelineCollection();
                PipelinePhase       phaseA    =
                    GetPipelineAndPhase("A", Phase.Output, pipelines, phaseResults, new[] { a1 }, Phase.Output);
                PipelinePhase phaseB =
                    GetPipelineAndPhase("B", Phase.Output, pipelines, phaseResults, new[] { b1, b2 }, Phase.Output, phaseA);
                PipelinePhase phaseC =
                    GetPipelineAndPhase("C", Phase.Output, pipelines, phaseResults, new[] { c1 }, Phase.Output, phaseB);

                phaseC.Pipeline.Deployment = true;
                PipelinePhase phaseD =
                    GetPipelineAndPhase("D", Phase.Output, pipelines, phaseResults, new[] { d1, d2 }, Phase.Output);

                phaseD.Pipeline.Deployment = true;
                PhaseOutputs documentCollection = new PhaseOutputs(phaseResults, phaseC, pipelines);

                // When
                IDocument[] result = documentCollection.ExceptPipeline("A").ToArray();

                // Then
                result.ShouldBe(new[] { b1, b2 }, true);
            }
            public void ThrowsForNonDependentPipelineDuringProcessPhase()
            {
                // Given
                TestDocument a1 = new TestDocument("a1");
                TestDocument b1 = new TestDocument("b1");
                TestDocument b2 = new TestDocument("b2");
                TestDocument c1 = new TestDocument("c1");
                TestDocument d1 = new TestDocument("d1");
                TestDocument d2 = new TestDocument("d2");
                ConcurrentDictionary <string, PhaseResult[]> phaseResults =
                    new ConcurrentDictionary <string, PhaseResult[]>(StringComparer.OrdinalIgnoreCase);
                IPipelineCollection pipelines = new TestPipelineCollection();
                PipelinePhase       phaseA    =
                    GetPipelineAndPhase("A", Phase.Process, pipelines, phaseResults, new[] { a1 });
                PipelinePhase phaseB =
                    GetPipelineAndPhase("B", Phase.Process, pipelines, phaseResults, new[] { b1, b2 }, phaseA);
                PipelinePhase phaseC =
                    GetPipelineAndPhase("C", Phase.Process, pipelines, phaseResults, new[] { c1 }, phaseB);
                PipelinePhase phaseD =
                    GetPipelineAndPhase("D", Phase.Process, pipelines, phaseResults, new[] { d1, d2 });
                ProcessPhaseOutputs documentCollection = new ProcessPhaseOutputs(phaseResults, phaseC, pipelines);

                // When, Then
                Should.Throw <InvalidOperationException>(() => documentCollection.FromPipeline("D"));
            }
            public void DoesNotThrowForCurrentPipelineDuringTransform()
            {
                // Given
                ConcurrentDictionary <string, PhaseResult[]> phaseResults =
                    new ConcurrentDictionary <string, PhaseResult[]>(StringComparer.OrdinalIgnoreCase);
                IPipelineCollection pipelines          = new TestPipelineCollection();
                PipelinePhase       phase              = GetPipelineAndPhase("A", Phase.Transform, pipelines, phaseResults, Array.Empty <IDocument>());
                ProcessPhaseOutputs documentCollection = new ProcessPhaseOutputs(phaseResults, phase, pipelines);

                // When, Then
                Should.NotThrow(() => documentCollection.FromPipeline("A"));
            }
            public void ThrowsForCurrentPipelineDuringProcess()
            {
                // Given
                ConcurrentDictionary <string, PhaseResult[]> phaseResults =
                    new ConcurrentDictionary <string, PhaseResult[]>(StringComparer.OrdinalIgnoreCase);
                IPipelineCollection pipelines          = new TestPipelineCollection();
                PipelinePhase       phase              = GetPipelineAndPhase("A", Phase.Process, pipelines, phaseResults, Array.Empty <IDocument>());
                ProcessPhaseOutputs documentCollection = new ProcessPhaseOutputs(phaseResults, phase, pipelines);

                // When, Then
                Should.Throw <InvalidOperationException>(() => documentCollection.FromPipeline("A"));
            }
Exemplo n.º 6
0
            public void ThrowsForEmptyPipeline()
            {
                // Given
                ConcurrentDictionary <string, PhaseResult[]> phaseResults =
                    new ConcurrentDictionary <string, PhaseResult[]>(StringComparer.OrdinalIgnoreCase);
                IPipelineCollection pipelines          = new TestPipelineCollection();
                PipelinePhase       phase              = GetPipelineAndPhase("A", Phase.Transform, pipelines, phaseResults, Array.Empty <IDocument>());
                PhaseOutputs        documentCollection = new PhaseOutputs(phaseResults, phase, pipelines);

                // When, Then
                Should.Throw <ArgumentException>(() => documentCollection.FromPipeline(string.Empty));
            }
            public void ThrowsForSelfDependency()
            {
                // Given
                IPipelineCollection pipelines = new TestPipelineCollection();

                pipelines.Add("Foo", new TestPipeline
                {
                    Dependencies = new HashSet <string>(new[] { "Foo" })
                });
                ILogger logger = new TestLoggerProvider().CreateLogger(null);

                // When, Then
                Should.Throw <PipelineException>(() => Engine.GetPipelinePhases(pipelines, logger));
            }
            public void ThrowsIfInputPhase()
            {
                // Given
                ConcurrentDictionary <string, PhaseResult[]> documents =
                    new ConcurrentDictionary <string, PhaseResult[]>(StringComparer.OrdinalIgnoreCase);
                IPipelineCollection pipelines = new TestPipelineCollection();
                PipelinePhase       phase     = GetPipelineAndPhase("A", Phase.Input, pipelines, documents, Array.Empty <IDocument>());

                phase.Pipeline.Isolated = true;
                ProcessPhaseOutputs documentCollection = new ProcessPhaseOutputs(documents, phase, pipelines);

                // When, Then
                Should.Throw <InvalidOperationException>(() => documentCollection.ToArray());
            }
Exemplo n.º 9
0
            public void DoesNotThrowForDeploymentDuringOutput()
            {
                // Given
                ConcurrentDictionary <string, PhaseResult[]> phaseResults =
                    new ConcurrentDictionary <string, PhaseResult[]>(StringComparer.OrdinalIgnoreCase);
                IPipelineCollection pipelines = new TestPipelineCollection();
                PipelinePhase       phase     = GetPipelineAndPhase("A", Phase.Output, pipelines, phaseResults, Array.Empty <IDocument>(), Phase.Output);

                phase.Pipeline.Deployment = true;
                GetPipelineAndPhase("B", Phase.Output, pipelines, phaseResults, Array.Empty <IDocument>(), Phase.Output);
                PhaseOutputs documentCollection = new PhaseOutputs(phaseResults, phase, pipelines);

                // When, Then
                Should.NotThrow(() => documentCollection.FromPipeline("B"));
            }
Exemplo n.º 10
0
            public void DoesNotThrowForManualDependency()
            {
                // Given
                IPipelineCollection pipelines = new TestPipelineCollection();

                pipelines.Add("Bar", new TestPipeline
                {
                    ExecutionPolicy = ExecutionPolicy.Manual
                });
                pipelines.Add("Foo", new TestPipeline
                {
                    Dependencies = new HashSet <string>(new[] { "Bar" })
                });
                ILogger logger = new TestLoggerProvider().CreateLogger(null);

                // When
                PipelinePhase[] phases = Engine.GetPipelinePhases(pipelines, logger);

                // Then
                phases.Select(x => (x.PipelineName, x.Phase)).ShouldBe(new (string, Phase)[]
            public void GetsDocumentsForInputPhaseDuringTransformPhase()
            {
                // Given
                TestDocument a1 = new TestDocument("a1");
                TestDocument a2 = new TestDocument("a2");
                TestDocument b1 = new TestDocument("b1");
                TestDocument b2 = new TestDocument("b2");
                ConcurrentDictionary <string, PhaseResult[]> phaseResults =
                    new ConcurrentDictionary <string, PhaseResult[]>(StringComparer.OrdinalIgnoreCase);
                IPipelineCollection pipelines = new TestPipelineCollection();
                PipelinePhase       phaseA    =
                    GetPipelineAndPhase("A", Phase.PostProcess, pipelines, phaseResults, new[] { a1, a2 }, Phase.Input);
                PipelinePhase phaseB =
                    GetPipelineAndPhase("B", Phase.PostProcess, pipelines, phaseResults, new[] { b1, b2 }, phaseA);
                PhaseOutputs documentCollection = new PhaseOutputs(phaseResults, phaseB, pipelines);

                // When
                IDocument[] result = documentCollection.FromPipeline("A").ToArray();

                // Then
                result.ShouldBe(new[] { a1, a2 });
            }