public void Middleware_can_wrap_the_response_of_an_application() { IApplication appWithoutMiddleware = new TheApp(); Assert.That(Application.GetResponse(appWithoutMiddleware, new Request()).BodyText, Is.EqualTo("Hello from the app")); IApplication appWithMiddleware = new MiddlewareThatWrapsBody(new TheApp()); Assert.That(Application.GetResponse(appWithMiddleware, new Request()).BodyText, Is.Not.EqualTo("Hello from the app")); Assert.That(Application.GetResponse(appWithMiddleware, new Request()).BodyText, Is.EqualTo("WRAPPED Hello from the app By Middleware!")); // another, passing args to constructor because we'll probably do something like this with Owin.Builder ... IMiddleware anotherApp = new MiddlewareThatWrapsBody("BEFORE:", ":AFTER"); anotherApp.InnerApplication = new TheApp(); Assert.That(Application.GetResponse(anotherApp, new Request()).BodyText, Is.EqualTo("BEFORE:Hello from the app:AFTER")); }
public void Middleware_can_wrap_the_response_of_an_application() { IApplication appWithoutMiddleware = new TheApp(); Assert.That(Application.GetResponse(appWithoutMiddleware, new Request()).BodyText, Is.EqualTo("Hello from the app")); IApplication appWithMiddleware = new MiddlewareThatWrapsBody(new TheApp()); Assert.That(Application.GetResponse(appWithMiddleware, new Request()).BodyText, Is.Not.EqualTo("Hello from the app")); Assert.That(Application.GetResponse(appWithMiddleware, new Request()).BodyText, Is.EqualTo("WRAPPED Hello from the app By Middleware!")); // another, passing args to constructor because we'll probably do something like this with Owin.Builder ... IMiddleware anotherApp = new MiddlewareThatWrapsBody("BEFORE:", ":AFTER"); anotherApp.InnerApplication = new TheApp(); Assert.That(Application.GetResponse(anotherApp, new Request()).BodyText, Is.EqualTo("BEFORE:Hello from the app:AFTER")); }