public void PipelineContext_SetProcessorOutput()
        {
            Pipeline        pipeline = TestPipelines.CreateMockProcessor1Pipeline();
            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 processor 1 producing an output of theResult="aString"
            context.SetProcessorOutputs(context.CurrentProcessor, new object[] { "aString" });

            // This should have been copied to the input slots for third processor
            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("aString", input[0], "Input should have contained this string");
        }
        public void PipelineContext_CurrentProcessor_Property()
        {
            Pipeline        pipeline = TestPipelines.CreateMockProcessor1Pipeline();
            PipelineContext context  = new PipelineContext(pipeline);

            Assert.IsNull(context.CurrentProcessor, "CurrentProcessor should be null before advance to first");

            Assert.IsTrue(context.AdvanceToNextProcessor(), "Failed to advance to first");
            Assert.AreSame(pipeline.Processors[0], context.CurrentProcessor, "First processor incorrect");

            Assert.IsTrue(context.AdvanceToNextProcessor(), "Failed to advance to second");
            Assert.AreSame(pipeline.Processors[1], context.CurrentProcessor, "Second processor incorrect");

            Assert.IsTrue(context.AdvanceToNextProcessor(), "Failed to advance to third");
            Assert.AreSame(pipeline.Processors[2], context.CurrentProcessor, "Third processor incorrect");

            Assert.IsFalse(context.AdvanceToNextProcessor(), "Moving off end should have returned false");
            Assert.IsNull(context.CurrentProcessor, "CurrentProcessor should be null after final advance");
        }
        public void PipelineContext_ReadAllInputs()
        {
            MockPipeline    pipeline = TestPipelines.CreateMockProcessor1Pipeline();
            PipelineContext context  = pipeline.Context;

            Assert.IsTrue(context.AdvanceToNextProcessor(), "Failed to advance to first");

            object[] input = context.ReadAllInputs(context.CurrentProcessor);
            Assert.IsNotNull(input, "Inputs for first processor should not be null");
            Assert.AreEqual(0, input.Length, "First processor should have zero inputs");

            Assert.IsTrue(context.AdvanceToNextProcessor(), "Failed to advance to second");
            input = context.ReadAllInputs(context.CurrentProcessor);
            Assert.IsNotNull(input, "Inputs for second processor should not be null");
            Assert.AreEqual(1, input.Length, "Second processor should have one input");

            Assert.IsTrue(context.AdvanceToNextProcessor(), "Failed to advance to third");
            input = context.ReadAllInputs(context.CurrentProcessor);
            Assert.IsNotNull(input, "Inputs for third processor should not be null");
            Assert.AreEqual(1, input.Length, "Third processor should have one input");
        }
        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");
        }