// [Fact]
        public void Create_Middleware_From_Class_That_Implements_IRequestMiddleware()
        {
            RequestMiddleware middleware =
                ClassMiddlewareFactory.Create <CustomMiddlewareThatImplementsInterface>();
            var contextMock = new Mock <IRequestContext>();

            middleware.Invoke(c => Task.CompletedTask).Invoke(contextMock.Object);
        }
        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();
        }
Esempio n. 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);
        }