public void Run_WithStrongTypedMiddleware_ShouldBeExecuted(IPipelineBuilder pipeline) { var data = new Data(); pipeline.For <Data>().Use <MiddlewareA>().Use <MiddlewareB>().Use <MiddlewareC>().Run(data); data.Steps[0].ShouldBe(MiddlewareA.Start); data.Steps[1].ShouldBe(MiddlewareB.Start); data.Steps[2].ShouldBe(MiddlewareC.Start); data.Steps[3].ShouldBe(MiddlewareC.End); data.Steps[4].ShouldBe(MiddlewareB.End); data.Steps[5].ShouldBe(MiddlewareA.End); }
public void Run_WithAnonymousMiddleware_ShouldBeExecuted(IPipelineBuilder pipeline) { var data = new Data(); pipeline.For <Data>() .Use((c, next) => { c.Data.Steps.Add("Start Anonymous A"); next(c); c.Data.Steps.Add("End Anonymous A"); }) .Use((c, next) => { c.Data.Steps.Add("Start Anonymous B"); next(c); c.Data.Steps.Add("End Anonymous B"); }) .Use((c, next) => { c.Data.Steps.Add("Start Anonymous C"); c.Data.Steps.Add("End Anonymous C"); }) .Run(data); data.Steps[0].ShouldBe("Start Anonymous A"); data.Steps[1].ShouldBe("Start Anonymous B"); data.Steps[2].ShouldBe("Start Anonymous C"); data.Steps[3].ShouldBe("End Anonymous C"); data.Steps[4].ShouldBe("End Anonymous B"); data.Steps[5].ShouldBe("End Anonymous A"); }