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(); }
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); }