Example #1
0
        public void CanAddMiddlewareInReversePhaseOrder()
        {
            var pipelineBuilder = new ResolvePipelineBuilder(PipelineType.Service);

            var order = new List <string>();

            pipelineBuilder.Use("3", PipelinePhase.Sharing, (ctxt, next) =>
            {
                order.Add("3");
                next(ctxt);
            });
            pipelineBuilder.Use("2", PipelinePhase.ScopeSelection, (ctxt, next) =>
            {
                order.Add("2");
                next(ctxt);
            });
            pipelineBuilder.Use("1", PipelinePhase.ResolveRequestStart, (ctxt, next) =>
            {
                order.Add("1");
                next(ctxt);
            });

            var built = pipelineBuilder.Build();

            built.Invoke(new PipelineRequestContextStub());

            Assert.Collection(
                order,
                el => Assert.Equal("1", el.ToString()),
                el => Assert.Equal("2", el.ToString()),
                el => Assert.Equal("3", el.ToString()));
        }
Example #2
0
        public void CanControlPhaseAddPriorityWithPrecedingPhase()
        {
            var pipelineBuilder = new ResolvePipelineBuilder(PipelineType.Service);

            var order = new List <string>();

            pipelineBuilder.Use("3", PipelinePhase.ScopeSelection, (ctxt, next) =>
            {
                order.Add("3");
                next(ctxt);
            });
            pipelineBuilder.Use("1", PipelinePhase.ResolveRequestStart, (ctxt, next) =>
            {
                order.Add("1");
                next(ctxt);
            });
            pipelineBuilder.Use("2", PipelinePhase.ScopeSelection, MiddlewareInsertionMode.StartOfPhase, (ctxt, next) =>
            {
                order.Add("2");
                next(ctxt);
            });

            var built = pipelineBuilder.Build();

            built.Invoke(new PipelineRequestContextStub());

            Assert.Collection(
                order,
                el => Assert.Equal("1", el.ToString()),
                el => Assert.Equal("2", el.ToString()),
                el => Assert.Equal("3", el.ToString()));
        }
Example #3
0
        public void CannotAddRegistrationMiddlewareToServicePipeline()
        {
            var pipelineBuilder = new ResolvePipelineBuilder(PipelineType.Service);
            var order           = new List <string>();

            Assert.Throws <InvalidOperationException>(() => pipelineBuilder.Use(PipelinePhase.RegistrationPipelineStart, (ctxt, next) => { }));
        }
Example #4
0
        public void CanHaveSingleStage()
        {
            var pipelineBuilder = new ResolvePipelineBuilder(PipelineType.Service);
            var order           = new List <string>();

            pipelineBuilder.Use(PipelinePhase.ResolveRequestStart, (ctxt, next) =>
            {
                order.Add("1");
                next(ctxt);
            });

            var built = pipelineBuilder.Build();

            built.Invoke(new PipelineRequestContextStub());

            Assert.Collection(
                order,
                e => Assert.Equal("1", e));
        }