public void CanRouteToARoute() { ITestWebApplication webApplication = Server .Configure() .OnRequest( c => { c.Get("/").To(request => Ok().WithJsonBody(new { a = 123 })); c.Post("/post").To(request => Ok().WithJsonBody(request)); }).StartTesting(); { var response = webApplication.Execute(Get()); response.AssertIsOk(); response.AssertJsonBodyMatches(new { a = 123 }); } { var response = webApplication.Execute(Post().WithPath("/post")); response.AssertIsOk(); response.AssertJsonBodyMatches(new { Path = "/post", Body = "", QueryParameters = new {}, Headers = new {}, Method = "POST" }); } webApplication.Stop(); }
public void ItCallsOnRequestOncePerRequest() { var numberOfTimesOnRequestCalled = 0; ITestWebApplication webApplication = Server .Configure() .OnRequest( _ => numberOfTimesOnRequestCalled++ ).StartTesting(); webApplication.Execute(Get()); webApplication.Execute(Get()); webApplication.Stop(); numberOfTimesOnRequestCalled.Should().Be(2); }