public void GivenThereIsNoCustomError_ThenTheError_IsHandled() { var controller = new TestableBaseController(this.logger.Object, this.userService.Object, this.appEnvironmentService.Object); var filterContext = new ExceptionContext(); MockHttpContext.Setup(h => h.IsCustomErrorEnabled).Returns(false); filterContext.HttpContext = MockHttpContext.Object; controller.OnException(filterContext); filterContext.ExceptionHandled.Should().BeFalse(); }
public void GivenThereIsACustomError_AndItIsNotAnHttpRequestValidationException_ThenTheViewIsSetToError() { var controller = new TestableBaseController(this.logger.Object, this.userService.Object, this.appEnvironmentService.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.As <ViewResult>().ViewName.Should().Be("Error"); }
public void GivenThereIsNoFilterContext_ThenTheError_IsNotHandled() { var controller = new TestableBaseController(this.logger.Object, this.userService.Object, this.appEnvironmentService.Object); controller.OnException(null); }