Skip to content

Instantly share code, notes, and snippets.

@marcusoftnet
Created January 18, 2013 10:22
Show Gist options
  • Select an option

  • Save marcusoftnet/4563651 to your computer and use it in GitHub Desktop.

Select an option

Save marcusoftnet/4563651 to your computer and use it in GitHub Desktop.
[Fact]
public void showing_the_complete_stack_testing_in_NancyTesting()
{
// Set up a browser to test MySimpleModule only
var browser = new Browser(with => with.Module(new MySimpleModule()));
// Perform a request, in this case a HTTP-GET to "/login"
// with a query-string
// But this can of course be any HTTP verb and you can send in
// forms, raw body-stream etc. Later blog-posts on that.
var response = browser.Get("/login", (with) => {
with.HttpRequest();
with.Query("error", "true");
});
// The returned response contains the generated view
// The view-template (for example a Razor-file) is executed
// and the data populated according to the model you supplied
// the view.
// Oh, almost forgot. There's some excellent Assertion-support
// using a CSS selector-style assertion library
response.Body["#errorBox"]
.ShouldExistOnce()
.And.ShouldBeOfClass("floatingError")
.And.ShouldContain(
"invalid",
StringComparison.InvariantCultureIgnoreCase);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment