Beispiel #1
0
        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();
        }
Beispiel #2
0
        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");
        }
Beispiel #3
0
        public void GivenThereIsNoFilterContext_ThenTheError_IsNotHandled()
        {
            var controller = new TestableBaseController(this.logger.Object, this.userService.Object, this.appEnvironmentService.Object);

            controller.OnException(null);
        }