var browser = new Browser(with => with.Module()); var response = browser.Get("/hello"); response.Body.AsString(); // "Hello, World!" response.StatusCode; // HttpStatusCode.OK
var browser = new Browser(with => with.ModuleIn this example, a POST request is made to the "/hello" route with a form value of "Alice". The response body and status code are checked, just like in the previous example. The Nancy.Testing Browser library is a part of the NancyFX library. It provides a higher-level abstraction for testing web applications built with NancyFX.()); var response = browser.Post("/hello", with => { with.HttpRequest(); with.FormValue("name", "Alice"); }); response.Body.AsString(); // "Hello, Alice!" response.StatusCode; // HttpStatusCode.OK