public void Test_Errors_NotFound_should_return_ViewResult_with_404_view() { var controller = new ErrorsController(); var result = controller.NotFound(); Assert.IsType <ViewResult>(result); var viewResult = result as ViewResult; Assert.Equal("404", viewResult.ViewName); }
public void NotFound() { // Arrange var context = new Mock <ControllerContext>(); context.Setup(x => x.HttpContext.Response.StatusCode).Verifiable(); using (var controller = new ErrorsController()) { controller.ControllerContext = context.Object; // Act var result = controller.NotFound() as ViewResult; // Assert Assert.IsNotNull(result); context.VerifySet(x => x.HttpContext.Response.StatusCode = 404); } }