コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
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);
        }