public async Task AfterModuleEventOverriddesOutputs()
            {
                // Given
                Engine      engine   = new Engine();
                IPipeline   pipeline = engine.Pipelines.Add("TestPipeline");
                CountModule module   = new CountModule("Foo")
                {
                    EnsureInputDocument = true
                };

                pipeline.ProcessModules.Add(module);
                CancellationTokenSource cts = new CancellationTokenSource();

                engine.Events.Subscribe <AfterModuleExecution>(x => x.OverrideOutputs(new TestDocument()
                {
                    { "Foo", x.Outputs[0].GetInt("Foo") + 123 }
                }.Yield()));

                // When
                IPipelineOutputs outputs = await engine.ExecuteAsync(cts.Token);

                // Then
                module.ExecuteCount.ShouldBe(1);
                outputs["TestPipeline"].Select(x => x.GetInt("Foo")).ShouldBe(new int[] { 124 });
            }
 internal AfterEngineExecution(IEngine engine, Guid executionId, IPipelineOutputs outputs, long elapsedMilliseconds)
 {
     Engine              = engine;
     ExecutionId         = executionId;
     Outputs             = outputs;
     ElapsedMilliseconds = elapsedMilliseconds;
 }
            public async Task ExecutesCorrectPipelines()
            {
                // Given
                Engine engine = new Engine();

                engine.Pipelines.Add(new TestExecutionPipeline());
                CancellationTokenSource cts = new CancellationTokenSource();

                // When
                IPipelineOutputs outputs = await engine.ExecuteAsync(cts.Token);

                // Then
                outputs["TestExecutionPipeline"].Cast <TestDocument>().Select(x => x.Content).Single().ShouldBe("Foo");
            }
            public async Task ExecutesModule()
            {
                // Given
                Engine      engine   = new Engine();
                IPipeline   pipeline = engine.Pipelines.Add("TestPipeline");
                CountModule module   = new CountModule("Foo")
                {
                    EnsureInputDocument = true
                };

                pipeline.ProcessModules.Add(module);
                CancellationTokenSource cts = new CancellationTokenSource();

                // When
                IPipelineOutputs outputs = await engine.ExecuteAsync(cts.Token);

                // Then
                module.ExecuteCount.ShouldBe(1);
                outputs["TestPipeline"].Select(x => x.GetInt("Foo")).ShouldBe(new int[] { 1 });
            }
 /// <summary>
 /// Gets and concatenates all documents from multiple pipelines.
 /// Note that if a document exists in more than one pipeline it
 /// may appear multiple times in the result.
 /// </summary>
 /// <param name="pipelineOutputs">The pipeline outputs.</param>
 /// <param name="pipelines">The pipeline(s) to get documents from.</param>
 /// <returns>All documents from all specified pipeline(s).</returns>
 public static DocumentList <IDocument> FromPipelines(
     this IPipelineOutputs pipelineOutputs,
     params string[] pipelines) =>
 (pipelines ?? Array.Empty <string>()).SelectMany(x => pipelineOutputs.FromPipeline(x)).ToDocumentList();