public void ProcessorCollection_Can_Have_No_Processors()
        {
            Processor containingProcessor = new MockNonGenericProcessor();
            ProcessorCollection processorCollection = new ProcessorCollection(containingProcessor);

            Assert.AreEqual(0, processorCollection.Count, "ProcessorCollection.Count should have been zero.");
        }
        public void OutArguments_Does_Not_Change_ProcessorArguments()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();
            ProcessorArgument       arg1      = new ProcessorArgument("arg1", typeof(string), "someProperty");
            ProcessorArgument       arg2      = new ProcessorArgument("arg2", typeof(Uri), "someOtherProperty", 5);
            ProcessorArgument       arg3      = new ProcessorArgument("arg3", typeof(int));

            processor.SetOutputArguments(arg1, arg2, arg3);

            ProcessorArgumentCollection arguments = processor.OutArguments;

            Assert.IsNotNull(arguments, "OutArguments should never be null.");
            Assert.AreEqual(3, arguments.Count, "OutArguments.Count should have returned 3.");

            Assert.AreSame(arg1, arguments[0], "The argument should have been the same instance as was provided by OnGetOutputArguments.");
            Assert.AreSame(arg2, arguments[1], "The argument should have been the same instance as was provided by OnGetOutputArguments.");
            Assert.AreSame(arg3, arguments[2], "The argument should have been the same instance as was provided by OnGetOutputArguments.");

            Assert.AreEqual("arg1", arguments[0].Name, "The argument name should have been the same as when it was created.");
            Assert.AreEqual("arg2", arguments[1].Name, "The argument name should have been the same as when it was created.");
            Assert.AreEqual("arg3", arguments[2].Name, "The argument name should have been the same as when it was created.");

            Assert.AreEqual(typeof(string), arguments[0].ArgumentType, "The argument type should have been the same as when it was created.");
            Assert.AreEqual(typeof(Uri), arguments[1].ArgumentType, "The argument type should have been the same as when it was created.");
            Assert.AreEqual(typeof(int), arguments[2].ArgumentType, "The argument type should have been the same as when it was created.");

            Assert.AreEqual(1, arguments[0].Properties.Count, "The argument should have the one property that it was created with.");
            Assert.AreEqual("someProperty", arguments[0].Properties.Find <string>(), "The argument should have the property value that it was created with.");

            Assert.AreEqual(2, arguments[1].Properties.Count, "The argument should have the two properties that it was created with.");
            Assert.AreEqual("someOtherProperty", arguments[1].Properties.Find <string>(), "The argument should have the property value that it was created with.");
            Assert.AreEqual(5, arguments[1].Properties.Find <int>(), "The argument should have the property value that it was created with.");

            Assert.AreEqual(0, arguments[2].Properties.Count, "The argument should not have any properties since it was not created with any.");
        }
Ejemplo n.º 3
0
        public void Bind_Unbind_Bind_Is_Equivalent_To_Bind()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();

            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();

            p2.SetInputArguments(new ProcessorArgument("p2In1", typeof(string)));

            ProcessorCollection       collection = new ProcessorCollection(new MockNonGenericProcessor(), p1, p2);
            PipelineBindingCollection bindings   = new PipelineBindingCollection(collection);

            bindings.BindArguments(p1.OutArguments[0], p2.InArguments[0]);
            Assert.AreEqual(1, bindings.GetBoundToArguments(p2.InArguments[0]).Count(), "Processor2 InArgument1 should have been bound to one other argument.");
            Assert.AreEqual(1, bindings.GetBoundToArguments(p1.OutArguments[0]).Count(), "Processor1 OutArgument1 should have been bound to one other argument.");
            Assert.AreSame(p1.OutArguments[0], bindings.GetBoundToArguments(p2.InArguments[0]).Single(), "Processor2 InArgument1 should have been bound to Processor1 OutArgument1.");
            Assert.AreSame(p2.InArguments[0], bindings.GetBoundToArguments(p1.OutArguments[0]).Single(), "Processor1 OutArgument1 should have been bound to Processor2 InArgument1.");

            bindings.UnbindArguments(p1.OutArguments[0], p2.InArguments[0]);
            Assert.AreEqual(0, bindings.GetBoundToArguments(p2.InArguments[0]).Count(), "Processor2 InArgument1 should not have been bound to any other arguments.");
            Assert.AreEqual(0, bindings.GetBoundToArguments(p1.OutArguments[0]).Count(), "Processor1 OutArgument1 should not have been bound to any other arguments.");

            bindings.BindArguments(p1.OutArguments[0], p2.InArguments[0]);
            Assert.AreEqual(1, bindings.GetBoundToArguments(p2.InArguments[0]).Count(), "Processor2 InArgument1 should have been bound to one other argument.");
            Assert.AreEqual(1, bindings.GetBoundToArguments(p1.OutArguments[0]).Count(), "Processor1 OutArgument1 should have been bound to one other argument.");
            Assert.AreSame(p1.OutArguments[0], bindings.GetBoundToArguments(p2.InArguments[0]).Single(), "Processor2 InArgument1 should have been bound to Processor1 OutArgument1.");
            Assert.AreSame(p2.InArguments[0], bindings.GetBoundToArguments(p1.OutArguments[0]).Single(), "Processor1 OutArgument1 should have been bound to Processor2 InArgument1.");
        }
        public void Execute_Allows_Null_Output_And_Null_Error_On_ProcessResult()
        {
            MockNonGenericProcessor processor   = new MockNonGenericProcessor();
            Exception       exception           = new Exception();
            ProcessorResult resultFromOnExecute = null;

            processor.OnExecuteAction = input =>
            {
                resultFromOnExecute = new ProcessorResult()
                {
                    Status = ProcessorStatus.Ok, Output = null, Error = null
                };
                return(resultFromOnExecute);
            };

            processor.Initialize();

            object[] inputObjArray = new object[1] {
                "hello"
            };
            ProcessorResult result = processor.Execute(inputObjArray);

            Assert.IsNotNull(result, "Processor.Execute should never return null.");
            Assert.AreEqual(ProcessorStatus.Ok, result.Status, "Processor.Execute should have returned the same value as returned from OnExecute.");
            Assert.AreSame(resultFromOnExecute, result, "Processor.Execute should have returned the same instance returned from OnExecute.");
            Assert.IsNull(result.Output, "Processor.Execute should have returned the same instance returned from OnExecute.");
            Assert.IsNull(result.Error, "Processor.Execute should have returned the same instance returned from OnExecute.");
        }
Ejemplo n.º 5
0
        public void Bind_Can_Bind_One_OutArgument_Multiple_Times()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();

            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();

            p2.SetInputArguments(new ProcessorArgument("p2In1", typeof(string)));

            MockNonGenericProcessor p3 = new MockNonGenericProcessor();

            p3.SetInputArguments(new ProcessorArgument("p3In1", typeof(string)));

            ProcessorCollection       collection = new ProcessorCollection(new MockNonGenericProcessor(), p1, p2, p3);
            PipelineBindingCollection bindings   = new PipelineBindingCollection(collection);

            bindings.BindArguments(p1.OutArguments[0], p2.InArguments[0]);
            bindings.BindArguments(p1.OutArguments[0], p3.InArguments[0]);
            Assert.AreEqual(2, bindings.GetBoundToArguments(p1.OutArguments[0]).Count(), "Processor1 OutArgument1 should have been bound to two other arguments.");
            Assert.AreSame(p2.InArguments[0], bindings.GetBoundToArguments(p1.OutArguments[0]).First(), "Processor1 OutArgument1 should have been bound to Processor2 InArgument1.");
            Assert.AreSame(p3.InArguments[0], bindings.GetBoundToArguments(p1.OutArguments[0]).Skip(1).First(), "Processor1 OutArgument1 should have been bound to Processor3 InArgument1.");
            Assert.AreSame(p1.OutArguments[0], bindings.GetBoundToArguments(p2.InArguments[0]).Single(), "Processor2 InArgument1 should have been bound to Processor1 OutArgument1.");
            Assert.AreSame(p1.OutArguments[0], bindings.GetBoundToArguments(p3.InArguments[0]).Single(), "Processor3 InArgument1 should have been bound to Processor1 OutArgument1.");
        }
Ejemplo n.º 6
0
        public void UnBind_Does_Nothing_If_Arguments_Are_Not_Bound()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();

            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();

            p2.SetOutputArguments(new ProcessorArgument("p2Out1", typeof(string)));

            MockNonGenericProcessor p3 = new MockNonGenericProcessor();

            p3.SetInputArguments(new ProcessorArgument("p3In1", typeof(string)));

            ProcessorCollection       collection = new ProcessorCollection(new MockNonGenericProcessor(), p1, p2, p3);
            PipelineBindingCollection bindings   = new PipelineBindingCollection(collection);

            bindings.BindArguments(p2.OutArguments[0], p3.InArguments[0]);
            Assert.AreEqual(0, bindings.GetBoundToArguments(p1.OutArguments[0]).Count(), "Processor1 OutArgument1 should not have been bound to any other arguments.");
            Assert.AreEqual(1, bindings.GetBoundToArguments(p2.OutArguments[0]).Count(), "Processor2 OutArgument1 should not have been bound to any other arguments.");
            Assert.AreEqual(1, bindings.GetBoundToArguments(p3.InArguments[0]).Count(), "Processor3 InArgument1 should not have been bound to any other arguments.");
            Assert.AreSame(p2.OutArguments[0], bindings.GetBoundToArguments(p3.InArguments[0]).Single(), "Processor3 InArgument1 should have been bound to Processor2 OutArgument1.");
            Assert.AreSame(p3.InArguments[0], bindings.GetBoundToArguments(p2.OutArguments[0]).Single(), "Processor2 OutArgument1 should have been bound to Processor3 InArgument1.");

            bindings.UnbindArguments(p1.OutArguments[0], p3.InArguments[0]);
            Assert.AreEqual(1, bindings.GetBoundToArguments(p2.OutArguments[0]).Count(), "Processor2 OutArgument1 should not have been bound to any other arguments.");
            Assert.AreEqual(1, bindings.GetBoundToArguments(p3.InArguments[0]).Count(), "Processor3 InArgument1 should not have been bound to any other arguments.");
            Assert.AreSame(p2.OutArguments[0], bindings.GetBoundToArguments(p3.InArguments[0]).Single(), "Processor3 InArgument1 should have been bound to Processor2 OutArgument1.");
            Assert.AreSame(p3.InArguments[0], bindings.GetBoundToArguments(p2.OutArguments[0]).Single(), "Processor2 OutArgument1 should have been bound to Processor3 InArgument1.");
        }
Ejemplo n.º 7
0
        public void ProcessorCollection_Can_Have_No_Processors()
        {
            Processor           containingProcessor = new MockNonGenericProcessor();
            ProcessorCollection processorCollection = new ProcessorCollection(containingProcessor);

            Assert.AreEqual(0, processorCollection.Count, "ProcessorCollection.Count should have been zero.");
        }
        public void OnError_ProcessorResult_Is_Not_Changed_By_Execute()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();

            Exception executionException = new Exception();

            object[] executionOutput = new object[0];
            processor.OnExecuteAction = input => new ProcessorResult
            {
                Status = ProcessorStatus.Error,
                Output = executionOutput,
                Error  = executionException
            };

            Exception onErrorException = new Exception();

            object[] onErrorOutput = new object[0];
            processor.OnErrorAction = result =>
            {
                Assert.AreEqual(ProcessorStatus.Error, result.Status, "The result status should have been ProcessorStatus.Error.");
                Assert.AreSame(result.Error, executionException, "The Error should have been the same instance as the one set in OnExecute.");
                Assert.AreSame(result.Output, executionOutput, "The Output should have been the same instance as the one set in OnExecute.");
                result.Error  = onErrorException;
                result.Output = onErrorOutput;
            };

            processor.Initialize();
            ProcessorResult resultFromExecute = processor.Execute(new object[0]);

            Assert.IsNotNull(resultFromExecute, "There should have been a non-null result.");
            Assert.AreEqual(ProcessorStatus.Error, resultFromExecute.Status, "The result status should have been ProcessorStatus.Error.");
            Assert.AreSame(resultFromExecute.Error, onErrorException, "The Error should have been the same instance as the one set in OnError.");
            Assert.AreSame(resultFromExecute.Output, onErrorOutput, "The Output should have been the same instance as the one set in OnError.");
        }
        public void Processor_Initializes_In_Correct_Order()
        {
            MockNonGenericProcessor mock = new MockNonGenericProcessor();
            int count = 0;

            mock.Initializing = new EventHandler(
                (obj, eArgs) =>
            {
                Assert.AreEqual(0, count, "Count should have been 0 because the Initializing event should have been called first.");
                Assert.IsFalse(mock.IsInitialized, "IsInitialized should be false.");
                count++;
            });

            mock.OnInitializeAction = () =>
            {
                Assert.AreEqual(1, count, "Count should have been 1 because the OnInitilize override should have been called second.");
                Assert.IsFalse(mock.IsInitialized, "IsInitialized should be false.");
                count++;
            };

            mock.Initialized = new EventHandler(
                (obj, eArgs) =>
            {
                Assert.AreEqual(2, count, "Count should have been 2 because the Initialized event should have been called third.");
                Assert.IsTrue(mock.IsInitialized, "IsInitialized should be true.");
                count++;
            });

            Assert.IsFalse(mock.IsInitialized, "IsInitialized should be false.");
            mock.Initialize();
            Assert.IsTrue(mock.IsInitialized, "IsInitialized should be true.");

            Assert.AreEqual(3, count, "Count should have been 3 because the Initialized event should have been called.");
        }
Ejemplo n.º 10
0
        public void ProcessorArgumentCollection_Can_Have_No_Arguments()
        {
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();

            processor1.SetInputArguments(new ProcessorArgument[0]);
            ProcessorArgumentCollection processor1InArguments = processor1.InArguments;

            Assert.AreEqual(0, processor1InArguments.Count, "The count or processor arguments should be zero.");
        }
        public void ContainingCollection_Should_Be_Non_Null_After_Adding_To_A_ProcessorArgumentCollection()
        {
            ProcessorArgument arg = new ProcessorArgument("AName", typeof(int));
            MockNonGenericProcessor processor = new MockNonGenericProcessor();
            processor.SetInputArguments(arg);
            ProcessorArgumentCollection collection = processor.InArguments;

            Assert.AreSame(collection, arg.ContainingCollection, "ProcessorArgument.ContainingColelction should be non-null after being added to the ProcessorArgumentCollection.");
        }
        public void ContainingCollection_Should_Be_Non_Null_After_Adding_To_A_ProcessorArgumentCollection()
        {
            ProcessorArgument       arg       = new ProcessorArgument("AName", typeof(int));
            MockNonGenericProcessor processor = new MockNonGenericProcessor();

            processor.SetInputArguments(arg);
            ProcessorArgumentCollection collection = processor.InArguments;

            Assert.AreSame(collection, arg.ContainingCollection, "ProcessorArgument.ContainingColelction should be non-null after being added to the ProcessorArgumentCollection.");
        }
        public void Index_Should_Be_Non_Null_After_Adding_To_A_ProcessorArgumentCollection()
        {
            ProcessorArgument       arg       = new ProcessorArgument("AName", typeof(int));
            MockNonGenericProcessor processor = new MockNonGenericProcessor();

            processor.SetInputArguments(arg);
            ProcessorArgumentCollection collection = processor.InArguments;

            Assert.AreEqual(0, arg.Index, "ProcessorArgument.Index should be 0 after being added to the ProcessorArgumentCollection.");
        }
        public void Index_Returns_Null_For_Non_Existing_Arguments()
        {
            ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string));
            ProcessorArgument arg2 = new ProcessorArgument("AnotherName", typeof(int));
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();
            processor1.SetInputArguments(arg1, arg2);
            ProcessorArgument processor1Arg = processor1.InArguments["SomeOtherName"];

            Assert.IsNull(processor1Arg, "ProcessorArgumentCollection.Index should have returned null because there is no argument with that name.");
        }
        public void Index_Returns_Argument()
        {
            ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string));
            ProcessorArgument arg2 = new ProcessorArgument("AnotherName", typeof(int));
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();
            processor1.SetInputArguments(arg1, arg2);
            ProcessorArgument processor1Arg = processor1.InArguments["AName"];

            Assert.AreSame(arg1, processor1Arg, "ProcessorArgumentCollection.Index should have returned the same instance.");
        }
        public void Index_Is_Case_Sensitive()
        {
            ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string));
            ProcessorArgument arg2 = new ProcessorArgument("AnotherName", typeof(int));
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();
            processor1.SetInputArguments(arg1, arg2);
            ProcessorArgument processor1Arg = processor1.InArguments["Aname"];

            Assert.IsNull(processor1Arg, "ProcessorArgumentCollection.Index should have returned null because the names differed by case.");
        }
Ejemplo n.º 17
0
        public void Index_Is_Case_Sensitive()
        {
            ProcessorArgument       arg1       = new ProcessorArgument("AName", typeof(string));
            ProcessorArgument       arg2       = new ProcessorArgument("AnotherName", typeof(int));
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();

            processor1.SetInputArguments(arg1, arg2);
            ProcessorArgument processor1Arg = processor1.InArguments["Aname"];

            Assert.IsNull(processor1Arg, "ProcessorArgumentCollection.Index should have returned null because the names differed by case.");
        }
Ejemplo n.º 18
0
        public void Index_Returns_Argument()
        {
            ProcessorArgument       arg1       = new ProcessorArgument("AName", typeof(string));
            ProcessorArgument       arg2       = new ProcessorArgument("AnotherName", typeof(int));
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();

            processor1.SetInputArguments(arg1, arg2);
            ProcessorArgument processor1Arg = processor1.InArguments["AName"];

            Assert.AreSame(arg1, processor1Arg, "ProcessorArgumentCollection.Index should have returned the same instance.");
        }
Ejemplo n.º 19
0
        public void ProcessorArgumentCollection_Can_Have_Two_Arguments_With_The_Same_Name_Different_Case()
        {
            ProcessorArgument       arg1       = new ProcessorArgument("AName", typeof(string));
            ProcessorArgument       arg2       = new ProcessorArgument("AnotherName", typeof(int));
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();

            processor1.SetInputArguments(arg1, arg2);
            ProcessorArgumentCollection processor1InArguments = processor1.InArguments;

            arg2.Name = "aname";
        }
        public void Execute_Throws_If_Initialize_Has_Not_Been_Called()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();

            ExceptionAssert.ThrowsInvalidOperation(
                "Execute should have thrown since the input parameter is null.",
                () =>
            {
                ProcessorResult resultFromExecute = processor.Execute(new object[0]);
            });
        }
Ejemplo n.º 21
0
        public void Index_Returns_Null_For_Non_Existing_Arguments()
        {
            ProcessorArgument       arg1       = new ProcessorArgument("AName", typeof(string));
            ProcessorArgument       arg2       = new ProcessorArgument("AnotherName", typeof(int));
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();

            processor1.SetInputArguments(arg1, arg2);
            ProcessorArgument processor1Arg = processor1.InArguments["SomeOtherName"];

            Assert.IsNull(processor1Arg, "ProcessorArgumentCollection.Index should have returned null because there is no argument with that name.");
        }
        public void InArguments_Returns_ProcessorArgumentCollection_with_Null_ProcessorArgument_Array()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();

            processor.SetInputArguments(null);

            ProcessorArgumentCollection arguments = processor.InArguments;

            Assert.IsNotNull(arguments, "InArguments should never be null.");
            Assert.AreEqual(ProcessorArgumentDirection.In, arguments.Direction, "InArguments.Direction ProcessorArgumentDirection.In");
            Assert.AreEqual(0, arguments.Count, "InArguments.Count should have been 0.");
        }
        public void InArguments_Returns_ProcessorArgumentCollection()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();

            processor.SetInputArguments(new ProcessorArgument("arg1", typeof(string)));

            ProcessorArgumentCollection arguments = processor.InArguments;

            Assert.IsNotNull(arguments, "InArguments should never be null.");
            Assert.AreEqual(ProcessorArgumentDirection.In, arguments.Direction, "InArguments.Direction ProcessorArgumentDirection.In");
            Assert.AreEqual(1, arguments.Count, "InArguments.Count should have been 1.");
        }
        public void OutArguments_Returns_ProcessorArgumentCollection_with_Empty_ProcessorArgument_Array()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();

            processor.SetOutputArguments(new ProcessorArgument[0]);

            ProcessorArgumentCollection arguments = processor.OutArguments;

            Assert.IsNotNull(arguments, "OutArguments should never be null.");
            Assert.AreEqual(ProcessorArgumentDirection.Out, arguments.Direction, "OutArguments.Direction ProcessorArgumentDirection.Out");
            Assert.AreEqual(0, arguments.Count, "OutArguments.Count should have been 0.");
        }
        public void ProcessorCollection_With_Null_ContainingProcessor_Throws()
        {
            Processor processor1 = new MockNonGenericProcessor();
            Processor processor2 = new MockNonGenericProcessor();

            ExceptionAssert.ThrowsArgumentNull(
                "Creating the ProcessorCollection with a null container processor should throw.",
                "containerProcessor",
                () =>
                {
                    ProcessorCollection processorCollection = new ProcessorCollection(null, processor1, processor2, processor1);
                });
        }
        public void ProcessorCollection_Cannot_Be_Created_With_The_ContainingProcessor_In_The_Processor_Collection()
        {
            Processor processor1 = new MockNonGenericProcessor();
            Processor processor2 = new MockNonGenericProcessor();
            Processor containingProcessor = new MockNonGenericProcessor();

            ExceptionAssert.ThrowsInvalidOperation(
                "Creating the ProcessorCollection with the containing processor in the list of processors should throw.",
                () =>
                {
                    ProcessorCollection processorCollection = new ProcessorCollection(containingProcessor, processor1, processor2, containingProcessor);
                });
        }
        public void ProcessorCollection_Cannot_Be_Created_With_A_Processor_Added_Twice()
        {
            Processor processor1 = new MockNonGenericProcessor();
            Processor processor2 = new MockNonGenericProcessor();
            Processor containingProcessor = new MockNonGenericProcessor();

            ExceptionAssert.ThrowsInvalidOperation(
                "Creating the ProcessorCollection with the processor2 in the list twice should throw.",
                () =>
                {
                    ProcessorCollection processorCollection = new ProcessorCollection(containingProcessor, processor1, processor2, processor1);
                });
        }
        public void ProcessorArgumentCollection_Cannot_Be_Created_With_The_Same_Argument_Twice()
        {
            ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string));
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();
            processor1.SetInputArguments(arg1, arg1);

            ExceptionAssert.ThrowsInvalidOperation(
                "Creating the argument collection with the same argument used twice should throw",
                () =>
                {
                    ProcessorArgumentCollection processor1InArguments = processor1.InArguments;
                });
        }
Ejemplo n.º 29
0
        public void ProcessorCollection_With_Null_ContainingProcessor_Throws()
        {
            Processor processor1 = new MockNonGenericProcessor();
            Processor processor2 = new MockNonGenericProcessor();

            ExceptionAssert.ThrowsArgumentNull(
                "Creating the ProcessorCollection with a null container processor should throw.",
                "containerProcessor",
                () =>
            {
                ProcessorCollection processorCollection = new ProcessorCollection(null, processor1, processor2, processor1);
            });
        }
Ejemplo n.º 30
0
        public void ProcessorCollection_Cannot_Be_Created_With_A_Processor_Added_Twice()
        {
            Processor processor1          = new MockNonGenericProcessor();
            Processor processor2          = new MockNonGenericProcessor();
            Processor containingProcessor = new MockNonGenericProcessor();

            ExceptionAssert.ThrowsInvalidOperation(
                "Creating the ProcessorCollection with the processor2 in the list twice should throw.",
                () =>
            {
                ProcessorCollection processorCollection = new ProcessorCollection(containingProcessor, processor1, processor2, processor1);
            });
        }
Ejemplo n.º 31
0
        public void ProcessorCollection_Cannot_Be_Created_With_The_ContainingProcessor_In_The_Processor_Collection()
        {
            Processor processor1          = new MockNonGenericProcessor();
            Processor processor2          = new MockNonGenericProcessor();
            Processor containingProcessor = new MockNonGenericProcessor();

            ExceptionAssert.ThrowsInvalidOperation(
                "Creating the ProcessorCollection with the containing processor in the list of processors should throw.",
                () =>
            {
                ProcessorCollection processorCollection = new ProcessorCollection(containingProcessor, processor1, processor2, containingProcessor);
            });
        }
        public void ProcessorCollection_Cannot_Be_Created_With_A_Null_Processor()
        {
            Processor processor1 = new MockNonGenericProcessor();
            Processor processor2 = new MockNonGenericProcessor();
            Processor containingProcessor = new MockNonGenericProcessor();

            ExceptionAssert.ThrowsArgumentNull(
                "Creating the ProcessorCollection with a null processor in the list should throw.",
                string.Empty,
                () =>
                {
                    ProcessorCollection processorCollection = new ProcessorCollection(containingProcessor, processor1, null, processor2);
                });
        }
        public void Execute_Throws_If_Input_Is_Null()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();

            processor.Initialize();

            ExceptionAssert.ThrowsArgumentNull(
                "Execute should have thrown since the input parameter is null.",
                "input",
                () =>
            {
                ProcessorResult resultFromExecute = processor.Execute(null);
            });
        }
Ejemplo n.º 34
0
        public void ProcessorCollection_Cannot_Be_Created_With_A_Null_Processor()
        {
            Processor processor1          = new MockNonGenericProcessor();
            Processor processor2          = new MockNonGenericProcessor();
            Processor containingProcessor = new MockNonGenericProcessor();

            ExceptionAssert.ThrowsArgumentNull(
                "Creating the ProcessorCollection with a null processor in the list should throw.",
                string.Empty,
                () =>
            {
                ProcessorCollection processorCollection = new ProcessorCollection(containingProcessor, processor1, null, processor2);
            });
        }
Ejemplo n.º 35
0
        public void ProcessorCollection_With_Null_Processors_Throws()
        {
            Processor processor1          = new MockNonGenericProcessor();
            Processor processor2          = new MockNonGenericProcessor();
            Processor containingProcessor = new MockNonGenericProcessor();

            ExceptionAssert.ThrowsArgumentNull(
                "Creating the ProcessorCollection with a null list of processors should throw.",
                "list",
                () =>
            {
                ProcessorCollection processorCollection = new ProcessorCollection(containingProcessor, null);
            });
        }
        public void InArguments_Returns_The_Same_ProcessorArgumentCollection_Instance_Every_Time()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();

            processor.SetInputArguments(new ProcessorArgument("arg1", typeof(string)));

            ProcessorArgumentCollection arguments1 = processor.InArguments;
            ProcessorArgumentCollection arguments2 = processor.InArguments;
            ProcessorArgumentCollection arguments3 = processor.InArguments;

            Assert.IsNotNull(arguments1, "InArguments should never be null.");
            Assert.AreSame(arguments1, arguments2, "InArguments should return the same instance every time.");
            Assert.AreSame(arguments1, arguments3, "InArguments should return the same instance every time.");
        }
Ejemplo n.º 37
0
        public void ProcessorArgumentCollection_Cannot_Be_Created_With_The_Same_Argument_Twice()
        {
            ProcessorArgument       arg1       = new ProcessorArgument("AName", typeof(string));
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();

            processor1.SetInputArguments(arg1, arg1);

            ExceptionAssert.ThrowsInvalidOperation(
                "Creating the argument collection with the same argument used twice should throw",
                () =>
            {
                ProcessorArgumentCollection processor1InArguments = processor1.InArguments;
            });
        }
        public void Execute_Default_ProcessResult_Is_Status_Ok_With_Null_Output()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();
            Exception exception = new Exception();
            processor.OnExecuteAction = input => new ProcessorResult();

            processor.Initialize();
            ProcessorResult result = processor.Execute(new object[0]);

            Assert.IsNotNull(result, "Processor.Execute should never return null.");
            Assert.AreEqual(ProcessorStatus.Ok, result.Status, "Processor.Execute should have returned the ProcessorStatus.Ok.");
            Assert.IsNull(result.Output, "Processor.Execute should have returned a null Output.");
            Assert.IsNull(result.Error, "Processor.Execute should have returned a null exception.");
        }
        public void Execute_Default_ProcessResult_Is_Status_Ok_With_Null_Output()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();
            Exception exception = new Exception();

            processor.OnExecuteAction = input => new ProcessorResult();

            processor.Initialize();
            ProcessorResult result = processor.Execute(new object[0]);

            Assert.IsNotNull(result, "Processor.Execute should never return null.");
            Assert.AreEqual(ProcessorStatus.Ok, result.Status, "Processor.Execute should have returned the ProcessorStatus.Ok.");
            Assert.IsNull(result.Output, "Processor.Execute should have returned a null Output.");
            Assert.IsNull(result.Error, "Processor.Execute should have returned a null exception.");
        }
Ejemplo n.º 40
0
        public void Unbind_With_In_Argument_Not_Attached_To_Processors_Throws()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();

            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));
            ProcessorCollection       collection = new ProcessorCollection(new MockNonGenericProcessor(), p1);
            PipelineBindingCollection bindings   = new PipelineBindingCollection(collection);

            ExceptionAssert.ThrowsInvalidOperation(
                "Unbind should have thrown because the in arugment does not belong to a processor",
                () =>
            {
                bindings.UnbindArguments(p1.OutArguments[0], new ProcessorArgument("someName", typeof(string)));
            });
        }
        public void OutArguments_With_Two_ProcessorArguments_With_Same_Name_Throws()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();
            ProcessorArgument       arg1      = new ProcessorArgument("arg1", typeof(string), "someProperty");
            ProcessorArgument       arg2      = new ProcessorArgument("arg1", typeof(int));

            processor.SetOutputArguments(arg1, arg2);

            ExceptionAssert.ThrowsInvalidOperation(
                "OutArguments should have thrown since there were two arguments with the same name.",
                () =>
            {
                ProcessorArgumentCollection arguments = processor.OutArguments;
            });
        }
        public void Copy_Creates_New_ProcessorArgument_Not_Attached_To_Any_Collection()
        {
            ProcessorArgument arg = new ProcessorArgument("AName", typeof(string));
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();
            processor1.SetInputArguments(arg);
            ProcessorArgumentCollection processor1InArguments = processor1.InArguments;

            ProcessorArgument argCopy = arg.Copy();

            Assert.IsNotNull(argCopy, "ProcessorArgument.Copy should not have returned null.");
            Assert.AreNotSame(arg, argCopy, "ProcessorArgument.Copy should have returned a new instance of ProcessorArgument.");
            Assert.IsNotNull(arg.ContainingCollection, "The original ProcessorArgument should have had a containing collection.");
            Assert.IsNull(argCopy.ContainingCollection, "The copied ProcessorArgument should not belong to any containing collection.");
            Assert.IsNotNull(arg.Index, "The original processor argument should have an index since it belongs to a collection.");
            Assert.IsNull(argCopy.Index, "The copied processor argument should not have an index since it does not belong to any containing collection.");
        }
        public void Execute_Does_Not_Change_ProcessResult_If_Not_Null()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();
            Exception exception = new Exception();
            ProcessorResult resultFromOnExecute = null;
            processor.OnExecuteAction = input =>
                {
                    resultFromOnExecute = new ProcessorResult() { Status = ProcessorStatus.Ok, Output = input, Error = exception };
                    return resultFromOnExecute;
                };

            processor.Initialize();

            object[] inputObjArray = new object[1] { "hello" };
            ProcessorResult result = processor.Execute(inputObjArray);

            Assert.IsNotNull(result, "Processor.Execute should never return null.");
            Assert.AreEqual(ProcessorStatus.Ok, result.Status, "Processor.Execute should have returned the same value as returned from OnExecute.");
            Assert.AreSame(resultFromOnExecute, result, "Processor.Execute should have returned the same instance returned from OnExecute.");
            Assert.AreSame(inputObjArray, result.Output, "Processor.Execute should have returned the same instance returned from OnExecute.");
            Assert.AreSame(exception, result.Error, "Processor.Execute should have returned the same instance returned from OnExecute.");
        }
        public void Bind_Can_Bind_One_OutArgument_Multiple_Times()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();
            p2.SetInputArguments(new ProcessorArgument("p2In1", typeof(string)));

            MockNonGenericProcessor p3 = new MockNonGenericProcessor();
            p3.SetInputArguments(new ProcessorArgument("p3In1", typeof(string)));

            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1, p2, p3);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            bindings.BindArguments(p1.OutArguments[0], p2.InArguments[0]);
            bindings.BindArguments(p1.OutArguments[0], p3.InArguments[0]);
            Assert.AreEqual(2, bindings.GetBoundToArguments(p1.OutArguments[0]).Count(), "Processor1 OutArgument1 should have been bound to two other arguments.");
            Assert.AreSame(p2.InArguments[0], bindings.GetBoundToArguments(p1.OutArguments[0]).First(), "Processor1 OutArgument1 should have been bound to Processor2 InArgument1.");
            Assert.AreSame(p3.InArguments[0], bindings.GetBoundToArguments(p1.OutArguments[0]).Skip(1).First(), "Processor1 OutArgument1 should have been bound to Processor3 InArgument1.");
            Assert.AreSame(p1.OutArguments[0], bindings.GetBoundToArguments(p2.InArguments[0]).Single(), "Processor2 InArgument1 should have been bound to Processor1 OutArgument1.");
            Assert.AreSame(p1.OutArguments[0], bindings.GetBoundToArguments(p3.InArguments[0]).Single(), "Processor3 InArgument1 should have been bound to Processor1 OutArgument1.");
        }
        public void Bind_Is_Idempotent()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();
            p2.SetInputArguments(new ProcessorArgument("p2In1", typeof(string)));

            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1, p2);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            bindings.BindArguments(p1.OutArguments[0], p2.InArguments[0]);
            Assert.AreEqual(1, bindings.GetBoundToArguments(p2.InArguments[0]).Count(), "Processor2 InArgument1 should have been bound to one other argument.");
            Assert.AreEqual(1, bindings.GetBoundToArguments(p1.OutArguments[0]).Count(), "Processor1 OutArgument1 should have been bound to one other argument.");
            Assert.AreSame(p1.OutArguments[0], bindings.GetBoundToArguments(p2.InArguments[0]).First(), "Processor2 InArgument1 should have been bound to Processor1 OutArgument1.");
            Assert.AreSame(p2.InArguments[0], bindings.GetBoundToArguments(p1.OutArguments[0]).First(), "Processor1 OutArgument1 should have been bound to Processor2 InArgument1.");

            bindings.BindArguments(p1.OutArguments[0], p2.InArguments[0]);
            Assert.AreEqual(1, bindings.GetBoundToArguments(p2.InArguments[0]).Count(), "Processor2 InArgument1 should have been bound to one other argument.");
            Assert.AreEqual(1, bindings.GetBoundToArguments(p1.OutArguments[0]).Count(), "Processor1 OutArgument1 should have been bound to one other argument.");
            Assert.AreSame(p1.OutArguments[0], bindings.GetBoundToArguments(p2.InArguments[0]).First(), "Processor2 InArgument1 should have been bound to Processor1 OutArgument1.");
            Assert.AreSame(p2.InArguments[0], bindings.GetBoundToArguments(p1.OutArguments[0]).First(), "Processor1 OutArgument1 should have been bound to Processor2 InArgument1.");
        }
        public void ProcessorArgumentCollection_With_A_Null_ProcessorArgument_Throws()
        {
            MockNonGenericProcessor processor = new MockNonGenericProcessor();
            ProcessorArgument arg1 = new ProcessorArgument("arg1", typeof(string), "someProperty");
            ProcessorArgument arg2 = null;
            ProcessorArgument arg3 = new ProcessorArgument("arg3", typeof(int));
            processor.SetInputArguments(arg1, arg2, arg3);

            ExceptionAssert.ThrowsArgumentNull(
                "ProcessorArgumentCollection should have thrown since a null ProcessorArgument was provided.",
                string.Empty,
                () =>
                {
                    ProcessorArgumentCollection arguments = processor.InArguments;
                });
        }
 public void ProcessorArgumentCollection_Can_Have_Two_Arguments_With_The_Same_Name_Different_Case()
 {
     ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string));
     ProcessorArgument arg2 = new ProcessorArgument("AnotherName", typeof(int));
     MockNonGenericProcessor processor1 = new MockNonGenericProcessor();
     processor1.SetInputArguments(arg1, arg2);
     ProcessorArgumentCollection processor1InArguments = processor1.InArguments;
     arg2.Name = "aname";
 }
        public void ProcessorArgumentCollection_Can_Have_No_Arguments()
        {
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();
            processor1.SetInputArguments(new ProcessorArgument[0]);
            ProcessorArgumentCollection processor1InArguments = processor1.InArguments;

            Assert.AreEqual(0, processor1InArguments.Count, "The count or processor arguments should be zero.");
        }
        public void Unbind_With_Out_Argument_On_Processors_Not_In_A_ProcessorCollection_Throws()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetInputArguments(new ProcessorArgument("p1In1", typeof(string)));
            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();
            p2.SetOutputArguments(new ProcessorArgument("p2Out1", typeof(string)));

            ExceptionAssert.ThrowsInvalidOperation(
                "Unbind should have thrown because the out arugment processor does not belong to any processor collection",
                () =>
                {
                    bindings.UnbindArguments(p2.OutArguments[0], p1.InArguments[0]);
                });
        }
        public void UnBind_Does_Not_Remove_Other_Bindings_On_An_InArgument()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();
            p2.SetOutputArguments(new ProcessorArgument("p2Out1", typeof(string)));

            MockNonGenericProcessor p3 = new MockNonGenericProcessor();
            p3.SetInputArguments(new ProcessorArgument("p3In1", typeof(string)));

            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1, p2, p3);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            bindings.BindArguments(p1.OutArguments[0], p3.InArguments[0]);
            bindings.BindArguments(p2.OutArguments[0], p3.InArguments[0]);

            bindings.UnbindArguments(p1.OutArguments[0], p3.InArguments[0]);
            Assert.AreEqual(1, bindings.GetBoundToArguments(p2.OutArguments[0]).Count(), "Processor2 OutArgument1 should not have been bound to any other arguments.");
            Assert.AreEqual(1, bindings.GetBoundToArguments(p3.InArguments[0]).Count(), "Processor3 InArgument1 should not have been bound to any other arguments.");
            Assert.AreSame(p2.OutArguments[0], bindings.GetBoundToArguments(p3.InArguments[0]).Single(), "Processor3 InArgument1 should have been bound to Processor2 OutArgument1.");
            Assert.AreSame(p3.InArguments[0], bindings.GetBoundToArguments(p2.OutArguments[0]).Single(), "Processor2 OutArgument1 should have been bound to Processor3 InArgument1.");
        }
        public void Unbind_With_OutArgument_That_Is_Not_Out_Direction_Throws()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetInputArguments(new ProcessorArgument("p1In1", typeof(string)));

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();
            p2.SetInputArguments(new ProcessorArgument("p2In1", typeof(string)));

            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1, p2);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            ExceptionAssert.ThrowsInvalidOperation(
                "Unbind should have thrown because the out arugment is not in the out direction.",
                () =>
                {
                    bindings.UnbindArguments(p1.InArguments[0], p2.InArguments[0]);
                });
        }
        public void Unbind_With_In_Arguments_On_Processors_Not_In_The_Same_ProcessorCollection_Throws()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));
            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();
            p2.SetInputArguments(new ProcessorArgument("p2In1", typeof(string)));
            ProcessorCollection otherCollection = new ProcessorCollection(new MockNonGenericProcessor(), p2);

            ExceptionAssert.ThrowsInvalidOperation(
                "Unbind should have thrown because the in arugment processor belongs to a different processor collection",
                () =>
                {
                    bindings.UnbindArguments(p1.OutArguments[0], p2.InArguments[0]);
                });
        }
        public void Unbind_With_InArgument_Processor_Before_OutArgument_Processor_Throws()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();
            p2.SetInputArguments(new ProcessorArgument("p2In1", typeof(string)));

            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p2, p1);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            ExceptionAssert.ThrowsInvalidOperation(
                "Unbind should have thrown because processor 1 comes after processor 2.",
                () =>
                {
                    bindings.UnbindArguments(p1.OutArguments[0], p2.InArguments[0]);
                });
        }
        public void Unbind_With_Arguments_On_The_Same_Processor_Throws()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));
            p1.SetInputArguments(new ProcessorArgument("p1In1", typeof(string)));
            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            ExceptionAssert.ThrowsInvalidOperation(
                "Unbind should have thrown because the in arugment and out argument belong to the same processor",
                () =>
                {
                    bindings.UnbindArguments(p1.OutArguments[0], p1.InArguments[0]);
                });
        }
        public void UnBind_Removes_The_Binding_If_Arguments_Are_Bound()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();
            p2.SetInputArguments(new ProcessorArgument("p2In1", typeof(string)));

            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1, p2);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            bindings.BindArguments(p1.OutArguments[0], p2.InArguments[0]);
            Assert.AreEqual(1, bindings.GetBoundToArguments(p2.InArguments[0]).Count(), "Processor2 InArgument1 should have been bound to one other argument.");
            Assert.AreEqual(1, bindings.GetBoundToArguments(p1.OutArguments[0]).Count(), "Processor1 OutArgument1 should have been bound to one other argument.");
            Assert.AreSame(p1.OutArguments[0], bindings.GetBoundToArguments(p2.InArguments[0]).Single(), "Processor2 InArgument1 should have been bound to Processor1 OutArgument1.");
            Assert.AreSame(p2.InArguments[0], bindings.GetBoundToArguments(p1.OutArguments[0]).Single(), "Processor1 OutArgument1 should have been bound to Processor2 InArgument1.");

            bindings.UnbindArguments(p1.OutArguments[0], p2.InArguments[0]);
            Assert.AreEqual(0, bindings.GetBoundToArguments(p2.InArguments[0]).Count(), "Processor2 InArgument1 should not have been bound to any other arguments.");
            Assert.AreEqual(0, bindings.GetBoundToArguments(p1.OutArguments[0]).Count(), "Processor1 OutArgument1 should not have been bound to any other arguments.");
        }
        public void ProcessorCollection_With_Null_Processors_Throws()
        {
            Processor processor1 = new MockNonGenericProcessor();
            Processor processor2 = new MockNonGenericProcessor();
            Processor containingProcessor = new MockNonGenericProcessor();

            ExceptionAssert.ThrowsArgumentNull(
                "Creating the ProcessorCollection with a null list of processors should throw.",
                "list",
                () =>
                {
                    ProcessorCollection processorCollection = new ProcessorCollection(containingProcessor, null);
                });
        }
        public void Unbind_With_OutArgument_Type_Not_Assignable_To_InArgument_Type_Throws()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(object)));

            MockNonGenericProcessor p2 = new MockNonGenericProcessor();
            p2.SetInputArguments(new ProcessorArgument("p2In1", typeof(Uri)));

            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1, p2);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            ExceptionAssert.ThrowsInvalidOperation(
                "Unbind should have thrown because the out arugment is not assignable to the in argument.",
                () =>
                {
                    bindings.UnbindArguments(p1.OutArguments[0], p2.InArguments[0]);
                });
        }
        public void GetBoundToArguments_Never_Returns_Null()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetOutputArguments(new ProcessorArgument("p1Out1", typeof(string)));

            ProcessorArgument arg2 = new ProcessorArgument("arg1", typeof(string));

            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            IEnumerable<ProcessorArgument> boundArguments = bindings.GetBoundToArguments(p1.OutArguments[0]);
            Assert.IsNotNull(boundArguments, "ProcessorBindingCollection.GetBoundArguments should never return null.");
            Assert.AreEqual(0, boundArguments.Count(), "ProcessorBindingCollection.GetBoundArguments should have returned an empty collection.");

            boundArguments = bindings.GetBoundToArguments(arg2);
            Assert.IsNotNull(boundArguments, "ProcessorBindingCollection.GetBoundArguments should never return null.");
            Assert.AreEqual(0, boundArguments.Count(), "ProcessorBindingCollection.GetBoundArguments should have returned an empty collection.");
        }
        public void ProcessorArgumentCollection_Cannot_Have_Two_Arguments_With_The_Same_Name()
        {
            ProcessorArgument arg1 = new ProcessorArgument("AName", typeof(string));
            ProcessorArgument arg2 = new ProcessorArgument("AnotherName", typeof(int));
            MockNonGenericProcessor processor1 = new MockNonGenericProcessor();
            processor1.SetInputArguments(arg1, arg2);
            ProcessorArgumentCollection processor1InArguments = processor1.InArguments;

            ExceptionAssert.ThrowsInvalidOperation(
                "Setting the argument name to something already in the argument collection should throw",
                () =>
                {
                    arg2.Name = "AName";
                });
        }
        public void Unbind_With_Out_Argument_Not_Attached_To_Processors_Throws()
        {
            MockNonGenericProcessor p1 = new MockNonGenericProcessor();
            p1.SetInputArguments(new ProcessorArgument("p1In1", typeof(string)));
            ProcessorCollection collection = new ProcessorCollection(new MockNonGenericProcessor(), p1);
            PipelineBindingCollection bindings = new PipelineBindingCollection(collection);

            ExceptionAssert.ThrowsInvalidOperation(
                "Unbind should have thrown because the out arugment does not belong to a processor",
                () =>
                {
                    bindings.UnbindArguments(new ProcessorArgument("someName", typeof(string)), p1.InArguments[0]);
                });
        }