public void Should_Not_Log_And_Set_Status_To_403_When_There_Is_A_Validation_Exception()
        {
            var outputWriter = Substitute.For<IOutputWriter>();
            var innerBehavior = Substitute.For<IActionBehavior>();
            var logger = Substitute.For<ILogger>();
            var exception = new ValidationException("why u enter bad data??");

            innerBehavior.When(x => x.Invoke()).Do(x => { throw exception; });

            var exceptionHandlerBehavior = new AjaxExceptionHandlerBehavior(innerBehavior, outputWriter, logger);

            exceptionHandlerBehavior.Invoke();

            innerBehavior.Received().Invoke();
            outputWriter.Received().WriteResponseCode(HttpStatusCode.BadRequest, exception.Message);
            logger.DidNotReceiveWithAnyArgs().LogException(null);
        }
        public void Should_Not_Log_And_Only_Set_Status_To_400_With_An_Json_Result_And_Validation_Exception()
        {
            var exceptionContext = new ExceptionContext();
            var logger = Substitute.For<ILogger>();
            var exception = new ValidationException("why u enter bad data??");

            exceptionContext.HttpContext = Substitute.For<HttpContextBase>();
            exceptionContext.Result = new JsonResult();
            exceptionContext.Exception = exception;
            exceptionContext.Controller = new DummyController();
            exceptionContext.RouteData = new RouteData();
            exceptionContext.RouteData.Values["action"] = "jsonaction";

            var exceptionHandlerFilter = new ExceptionHandlerFilter(logger);

            exceptionHandlerFilter.OnException(exceptionContext);

            exceptionContext.HttpContext.Response.StatusCode.ShouldEqual(400);
            exceptionContext.HttpContext.Response.StatusDescription.ShouldEqual(exception.Message);
            exceptionContext.ExceptionHandled.ShouldBeTrue();
            logger.DidNotReceiveWithAnyArgs().LogException(null);
        }