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 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 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 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."); }