Exemplo n.º 1
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);
        }
Exemplo n.º 2
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
        }