public void PipelineContext_Ctor_Internal_Null_ContextInfo_Creates()
 {
     Processor processor = new MockProcessor1();
     Pipeline pipeline = new Pipeline(new[] { processor }, Enumerable.Empty<ProcessorArgument>(), Enumerable.Empty<ProcessorArgument>());
     PipelineContext context = new PipelineContext(pipeline, null);
     Assert.IsNotNull(context.ContextInfo, "Null contextInfo to ctor should have created one");
 }
 public void PipelineContext_Ctor_Internal_Accepts_ContextInfo()
 {
     Processor processor = new MockProcessor1();
     Pipeline pipeline = new Pipeline(new[] { processor }, Enumerable.Empty<ProcessorArgument>(), Enumerable.Empty<ProcessorArgument>());
     PipelineContextInfo info = new PipelineContextInfo(pipeline);
     PipelineContext context = new PipelineContext(pipeline, info);
     Assert.AreSame(info, context.ContextInfo, "Ctor should have used the ContextInfo we passed int.");
 }
        public void PipelineContext_Ctor_Internal_Reuses_Pipeline_ContextInfo()
        {
            Processor processor = new MockProcessor1();
            Pipeline pipeline = new Pipeline(new[] { processor }, Enumerable.Empty<ProcessorArgument>(), Enumerable.Empty<ProcessorArgument>());
            PipelineContext context1 = new PipelineContext(pipeline);
            Assert.IsNotNull(context1.ContextInfo, "ContextInfo should have been created");

            PipelineContext context2 = new PipelineContext(pipeline);
            Assert.AreSame(context1.ContextInfo, context2.ContextInfo, "Expected 2nd context to reuse same ContextInfo");
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PipelineContext"/> class.
 /// </summary>
 /// <param name="pipeline">The <see cref="Pipeline"/> that will use this <see cref="PipelineContext"/>.</param>
 public PipelineContext(Pipeline pipeline)
 {
     this.Initialize(pipeline, null);
 }
 internal PipelineContext(Pipeline pipeline, PipelineContextInfo contextInfo)
 {
     this.Initialize(pipeline, contextInfo);
 }
        public void Pipeline_BindArgument_Throws_Null_InArg()
        {
            MockProcessor1 processor = new MockProcessor1();
            Pipeline pipeline = new Pipeline(
                new Processor[] { processor },
                Enumerable.Empty<ProcessorArgument>(),
                Enumerable.Empty<ProcessorArgument>());

            ExceptionAssert.ThrowsArgumentNull(
                "BindArgument with null in should throw",
                "inArgument",
                () => pipeline.BindArguments(processor.OutArguments[0], null)
                );
        }
        private void Initialize(Pipeline pipeline, PipelineContextInfo contextInfo)
        {
            if (pipeline == null)
            {
                throw new ArgumentNullException("pipeline");
            }

            this.Pipeline = pipeline;

            // A null contextInfo indicates we should reuse the one created
            // and retained by the pipeline.  This is the nominal execution
            // path.
            if (contextInfo == null)
            {
                contextInfo = pipeline.ContextInfo;
            }
            else
            {
                Debug.Assert(contextInfo.Pipeline == pipeline, "Cannot use contextInfo from a different pipeline");
            }

            this.ContextInfo = contextInfo;
            this.CurrentProcessorIndex = -1;
        }
        public void Pipeline_UnbindArgument_Throws_After_Initialize()
        {
            MockProcessor1 processor1 = new MockProcessor1();
            MockProcessorEchoString processor2 = new MockProcessorEchoString();
            Pipeline pipeline = new Pipeline(
                new Processor[] { processor1, processor2 },
                Enumerable.Empty<ProcessorArgument>(),
                Enumerable.Empty<ProcessorArgument>());

            pipeline.Initialize();

            ExceptionAssert.ThrowsInvalidOperation(
                "UnbindArgument should throw if called after initialize",
                () => pipeline.UnbindArguments(processor1.OutArguments[0], processor2.InArguments[0])
                );
        }
        public void Pipeline_UnbindArgument_Throws_Null_OutArg()
        {
            MockProcessor1 processor = new MockProcessor1();
            Pipeline pipeline = new Pipeline(
                new Processor[] { processor },
                Enumerable.Empty<ProcessorArgument>(),
                Enumerable.Empty<ProcessorArgument>());

            ExceptionAssert.ThrowsArgumentNull(
                "UnbindArgument with null out should throw",
                "outArgument",
                () => pipeline.UnbindArguments(null, processor.InArguments[0])
                );
        }
        public void Pipeline_Processor_Belongs_To_Only_1_Pipeline()
        {
            Processor processor = new MockProcessor1();
            Pipeline pipeline1 = new Pipeline(new[] { processor }, Enumerable.Empty<ProcessorArgument>(), Enumerable.Empty<ProcessorArgument>());

            Assert.AreEqual(pipeline1, processor.ContainingCollection.ContainerProcessor, "Processor.Pipeline must be the pipeline we created");

            Pipeline pipeline2;
            ExceptionAssert.ThrowsInvalidOperation(
                "Adding a processor to a 2nd pipeline should throw",
                () => pipeline2 = new Pipeline(new[] { processor }, Enumerable.Empty<ProcessorArgument>(), Enumerable.Empty<ProcessorArgument>())
                );
        }
        public void Pipeline_UnbindArgument_Succeeds()
        {
            MockProcessor1 processor1 = new MockProcessor1();
            MockProcessorEchoString processor2 = new MockProcessorEchoString();
            Pipeline pipeline = new Pipeline(
                new Processor[] { processor1, processor2 },
                Enumerable.Empty<ProcessorArgument>(),
                Enumerable.Empty<ProcessorArgument>());

            pipeline.BindArguments(processor1.OutArguments[0], processor2.InArguments[0]);
            Assert.IsTrue(
                pipeline.GetBoundToArguments(processor1.OutArguments[0]).Contains(processor2.InArguments[0]),
                "Expected GetBoundTo(out) to show we bound out to in");
            Assert.IsTrue(
                pipeline.GetBoundToArguments(processor2.InArguments[0]).Contains(processor1.OutArguments[0]),
                "Expected GetBoundTo(in) to show we bound out to in");

            pipeline.UnbindArguments(processor1.OutArguments[0], processor2.InArguments[0]);

            Assert.IsFalse(
                pipeline.GetBoundToArguments(processor1.OutArguments[0]).Contains(processor2.InArguments[0]),
                "Expected GetBoundTo(out) to show we unbound out to in");
            Assert.IsFalse(
                pipeline.GetBoundToArguments(processor2.InArguments[0]).Contains(processor1.OutArguments[0]),
                "Expected GetBoundTo(in) to show we unbound out to in");
        }
        public void Pipeline_GetBoundToArguments_Throws_Null_Parameer()
        {
            MockProcessor1 processor = new MockProcessor1();
            Pipeline pipeline = new Pipeline(
                Enumerable.Empty <Processor>(),
                Enumerable.Empty<ProcessorArgument>(),
                Enumerable.Empty<ProcessorArgument>());

            ExceptionAssert.ThrowsArgumentNull(
                "GetBoundToArguments should throw for null parameter",
                "argument",
                () => pipeline.GetBoundToArguments(null)
                );
        }
 public void Pipeline_Ctor_Throws_Null_Processors()
 {
     Pipeline p;
     ExceptionAssert.ThrowsArgumentNull(
         "Pipeline ctor should throw if processor collection is null",
         "processors",
         () => p = new Pipeline(null, Enumerable.Empty<ProcessorArgument>(), Enumerable.Empty<ProcessorArgument>())
         );
 }
 public void Pipeline_Ctor_Throws_Null_OutArguments()
 {
     Processor processor = new MockProcessor1();
     Pipeline p;
     ExceptionAssert.ThrowsArgumentNull(
         "Pipeline ctor should throw if processor collection is null",
         "outArguments",
         () => p = new Pipeline(new[] { processor }, Enumerable.Empty<ProcessorArgument>(), null)
         );
 }
Ejemplo n.º 15
0
 public PipelineEntryProcessor(Pipeline pipeline)
 {
     this.Pipeline = pipeline;
 }
        public void Initialize()
        {
            var builder = this.Builder;
            if (builder == null)
            {
                builder = new PipelineBuilder();
            }

            this.requestPipeline = builder.Build(this.requestProcessors, GetRequestInArguments(), this.GetRequestOutArguments());
            this.responsePipeline = builder.Build(this.responseProcessors, this.GetResponseInArguments(), Enumerable.Empty<ProcessorArgument>());
        }
Ejemplo n.º 17
0
 public PipelineExitProcessor(Pipeline pipeline)
 {
     this.Pipeline = pipeline;
 }
 public PipelineContextInfo(Pipeline pipeline)
 {
     Debug.Assert(pipeline != null, "pipeline cannot be null");
     this.Pipeline = pipeline;
     this.Initialize();
 }