public async Task contributor_executed()
        {
            Env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.Abort;

            var middleware = new ResponseMiddleware(Contributor(e => Task.FromResult(PipelineContinuation.Continue)));
            await middleware.Invoke(Env);

            ContributorCalled.ShouldBeTrue();
            Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.Abort);
        }
        public async Task middleware_throws()
        {
            Env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.Continue;

            var middleware = new ResponseMiddleware(Contributor(e => Task.FromResult(PipelineContinuation.Abort)));

            middleware.Invoke(Env).ShouldThrow <PipelineAbortedException>();

            ContributorCalled.ShouldBeTrue();
            Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.Abort);
        }
        public async Task middleware_continues()
        {
            var middleware = new PreExecuteMiddleware(
                Contributor(e => Task.FromResult(PipelineContinuation.RenderNow)))
                             .Compose(Next);
            await middleware.Invoke(Env);

            ContributorCalled.ShouldBeTrue();
            NextCalled.ShouldBeTrue();
            Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.RenderNow);
        }
        public async Task contributor_not_executed()
        {
            Env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.RenderNow;

            var middleware = new RequestMiddleware(
                Contributor(e => Task.FromResult(PipelineContinuation.Continue)))
                             .Compose(Next);
            await middleware.Invoke(Env);

            NextCalled.ShouldBeTrue();
            ContributorCalled.ShouldBeFalse();
        }
Example #5
0
        public async Task next_middleware_isnt_executed()
        {
            Env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.Continue;

            var middleware = new ResponseMiddleware(
                Contributor(e => Task.FromResult(PipelineContinuation.RenderNow)));
            await middleware.Invoke(Env);

            ContributorCalled.ShouldBeTrue();
            NextCalled.ShouldBeFalse();
            Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.RenderNow);
        }
Example #6
0
        public async Task pipeline_is_in_RenderNow()
        {
            Env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.Continue;
            var middleware = new RequestMiddleware(Contributor(e => Task.FromResult(PipelineContinuation.RenderNow)))
                             .Compose(Next);

            await middleware.Invoke(Env);

            ContributorCalled.ShouldBeTrue();
            NextCalled.ShouldBeTrue();

            Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.RenderNow);
        }
        public async Task contributor_executed()
        {
            Env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.Continue;

            var middleware = new RequestMiddleware(
                Contributor(e => { throw new InvalidOperationException("Should not throw"); }))
                             .Compose(Next);
            await middleware.Invoke(Env);

            ContributorCalled.ShouldBeTrue();
            NextCalled.ShouldBeTrue();

            Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.Abort);
        }
Example #8
0
        public void middleware_throws()
        {
            var middleware = new PreExecuteMiddleware(Contributor(e => Task.FromResult(PipelineContinuation.Abort)))
                             .Compose(Next);

            middleware.Invoke(Env).ShouldThrow <PipelineAbortedException>();

            ContributorCalled.ShouldBeTrue();
            NextCalled.ShouldBeFalse();

#pragma warning disable 618
            Env.PipelineData.PipelineStage.CurrentState.ShouldBe(PipelineContinuation.Abort);
#pragma warning restore 618
        }