public void Request_ForApiController_Throws_WhenControllerRequestIsNull() { // Arrange ApiController controller = CreateController(); Assert.Null(controller.Request); InternalServerErrorResult result = CreateProductUnderTest(controller); // Act & Assert InvalidOperationException exception = Assert.Throws<InvalidOperationException>(() => { HttpRequestMessage ignore = result.Request; }, "ApiController.Request must not be null."); }
public void Request_Returns_InstanceProvided() { // Arrange using (HttpRequestMessage expectedRequest = CreateRequest()) { InternalServerErrorResult result = CreateProductUnderTest(expectedRequest); // Act HttpRequestMessage request = result.Request; // Assert Assert.Same(expectedRequest, request); } }
public void ApiControllerInternalServerError_CreatesCorrectResult() { // Arrange ApiController controller = CreateController(); // Act InternalServerErrorResult result = controller.InternalServerError(); // Assert Assert.NotNull(result); using (HttpRequestMessage expectedRequest = CreateRequest()) { controller.Request = expectedRequest; Assert.Same(expectedRequest, result.Request); } }
public void Request_ForApiController_EvaluatesLazily() { // Arrange ApiController controller = CreateController(); InternalServerErrorResult result = CreateProductUnderTest(controller); using (HttpRequestMessage expectedRequest = CreateRequest()) { controller.Request = expectedRequest; // Act HttpRequestMessage request = result.Request; // Assert Assert.Same(expectedRequest, request); } }