Reputation: 63
I'm new to developing with the Nancy, and I'm stumped as to why the response body to my test method is returning "[ERR!]" as opposed to the markup that I'm expecting.
private BrowserResponse _response;
[Test]
public void GetLoginIsOk()
{
var accountDatabase = new AccountDatabase();
var loginModule = new LoginModule(accountDatabase);
var browser = new Browser(c => c.Module(loginModule));
_response = browser.Get("/login");
_response.StatusCode.ShouldBe(HttpStatusCode.OK);
Console.Write(_response.Body.AsString());
}
The test is passing (i.e. the status code returned is OK). But, I'd like to do additional validation on the markup returned so that the expected form fields do in fact exist.
Upvotes: 1
Views: 315
Reputation: 63
I figured out what my issue was. I had set up a master page and forgot to set that to copy out to the output directory.
Upvotes: 2
Reputation: 4932
To test the mark-up can use selectors to query the body, like so:
_response.Body["#someelement"].ShouldExist();
See the documentation for details
Upvotes: 2