コード例 #1
0
        public void ExceptionShouldBeWrittenToHeader()
        {
            const string error = "oh my, an exception!";

            _controller = TestControllerBuilder.TestController().Build();

            var context = new ExceptionContext { Exception = new Exception(error) };
            _controller.ThrowException(context);

            _controller.Headers.Get(Constants.Headers.ErrorMessage).ShouldEqual(error);
        }
コード例 #2
0
        public void ExceptionShouldBeWrittenToHeaderIfRealExceptionsAreTurnedOff()
        {
            const string realError = "real error";
            const string shownError = "shown error";

            _controller = TestControllerBuilder.TestController().Build();
            RestCore.Configuration = new Configuration {HideRealException = true, DefaultExceptionText = shownError};

            var context = new ExceptionContext { Exception = new Exception(realError) };
            _controller.ThrowException(context);

            _controller.Headers.Get(Constants.Headers.ErrorMessage).ShouldEqual(shownError);
        }
コード例 #3
0
        public void UnknownServerErrorCodeShouldBeWrittenToHeaderIfSet()
        {
            const int unknownServerErrorCode = 14;

            _controller = TestControllerBuilder.TestController().Build();
            RestCore.Configuration = new Configuration { UnknownServerErrorCode = unknownServerErrorCode };

            var context = new ExceptionContext { Exception = new Exception("error") };
            _controller.ThrowException(context);

            _controller.Headers.Get(Constants.Headers.ErrorCode).ShouldEqual(unknownServerErrorCode.ToString());
        }