Created
May 12, 2013 09:30
-
-
Save mauricedb/5562976 to your computer and use it in GitHub Desktop.
Unit test an ASP.NET ApiController that uses the ApiController.Request property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void GetWithAnUnknownIdShouldReturnNotFound() | |
{ | |
// Arrange | |
var controller = new BooksController() | |
{ | |
Request = new HttpRequestMessage() | |
{ | |
Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } } | |
} | |
}; | |
// Act | |
var response = controller.Get(999); | |
// Assert | |
Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment