public void GivenThereIsNoFilterContext_ThenTheErrorIsNotHandled() { var controller = new TestableBaseController(_logger.Object); controller.OnException(null); }
public void GivenThereIsACustomError_AndItIsNotAnHttpRequestValidationException_ThenTheViewIsSetToTheErrorView() { var controller = new TestableBaseController(_logger.Object); var filterContext = new ExceptionContext(); MockHttpContext.Setup(h => h.IsCustomErrorEnabled).Returns(true); filterContext.HttpContext = MockHttpContext.Object; filterContext.Exception = new Exception(); controller.OnException(filterContext); filterContext.Result.Should().BeOfType<ViewResult>(); }
public void GivenThereIsNoCustomError_ThenTheErrorIsHandled() { var controller = new TestableBaseController(_logger.Object); var filterContext = new ExceptionContext(); MockHttpContext.Setup(h => h.IsCustomErrorEnabled).Returns(false); filterContext.HttpContext = MockHttpContext.Object; controller.OnException(filterContext); filterContext.ExceptionHandled.Should().BeFalse(); }