public void Pipeline_Executes_2_Processors_Common_In_Double_Out() { Pipeline pipeline = TestPipelines.CreateDoubleMockProcessor1Pipeline(); // Override the OnExecute of both so we see unique outputs ((MockProcessor1)pipeline.Processors[1]).OnExecuteCalled = i => new ProcessorResult <string>() { Output = "result1 for " + i }; ((MockProcessor1)pipeline.Processors[2]).OnExecuteCalled = i => new ProcessorResult <string>() { Output = "result2 for " + i }; ProcessorResult result = pipeline.Execute(new object[] { 5 }); // This test has 2 MockProcessor1's, both bound to the single pipeline input 'intValue'. // Each processor output is bound to one of the 2 pipeline outputs object[] output = result.Output; Assert.IsNotNull(output, "Processing output was null"); Assert.AreEqual(2, output.Length, "Should have received 1 output"); Assert.AreEqual("result1 for 5", output[0], "Should have seen this output[0]"); Assert.AreEqual("result2 for 5", output[1], "Should have seen this output[1]"); }
public void PipelineContext_SetProcessorOutput_Fanout_2_Processors() { Pipeline pipeline = TestPipelines.CreateDoubleMockProcessor1Pipeline(); PipelineContext context = new PipelineContext(pipeline); Assert.IsTrue(context.AdvanceToNextProcessor(), "Failed to advance to first"); // Mimic entry processor producing its output of an intValue=5 context.SetProcessorOutputs(context.CurrentProcessor, new object[] { 5 }); // This should have been copied to the input slots for second processor Assert.IsTrue(context.AdvanceToNextProcessor(), "Failed to advance to second"); object[] input = context.ReadAllInputs(context.CurrentProcessor); Assert.IsNotNull(input, "Input cannot be null"); Assert.AreEqual(1, input.Length, "Expected 1 element in input"); Assert.AreEqual(5, input[0], "Input should have contained a 5"); // Mimic second processor setting its output to "aString1" context.SetProcessorOutputs(context.CurrentProcessor, new object[] { "aString1" }); // Move to 3rd processor and ensure it got the same inputs as 2nd Assert.IsTrue(context.AdvanceToNextProcessor(), "Failed to advance to third"); input = context.ReadAllInputs(context.CurrentProcessor); Assert.IsNotNull(input, "Input cannot be null"); Assert.AreEqual(1, input.Length, "Expected 1 element in input"); Assert.AreEqual(5, input[0], "Input should have contained a 5"); // Mimic third processor setting its output to "aString2" context.SetProcessorOutputs(context.CurrentProcessor, new object[] { "aString2" }); // This should have been copied to the input slots for final processor Assert.IsTrue(context.AdvanceToNextProcessor(), "Failed to advance to third"); input = context.ReadAllInputs(context.CurrentProcessor); Assert.IsNotNull(input, "Input cannot be null"); Assert.AreEqual(2, input.Length, "Expected 2 elements in input"); Assert.AreEqual("aString1", input[0], "Input[0] should have contained this string"); Assert.AreEqual("aString2", input[1], "Input[1] should have contained this string"); }