コード例 #1
0
        public void GivenAnError_ThenAJSONViewResult_Isreturned()
        {
            var controller = new TestableBaseController(this.logger.Object, this.userService.Object, this.appEnvironmentService.Object);

            this.SetControllerContext(controller);
            var error = controller.JsonError(new Exception(), new ErrorCode(), String.Empty);

            error.Should().BeOfType <JsonResult>();
        }
コード例 #2
0
        public void GivenAnError_ThenTheJSONViewResultContains_TheCorrectData()
        {
            var controller = new TestableBaseController(this.logger.Object, this.userService.Object, this.appEnvironmentService.Object);

            this.SetControllerContext(controller);
            const ErrorCode Code  = new ErrorCode();
            var             ex    = new Exception("error message");
            var             error = controller.JsonError(ex, Code, "message");

            error.As <JsonResult>().Data.As <ErrorViewModel>().DisplayMessage.Should().Be("message");
            error.As <JsonResult>().Data.As <ErrorViewModel>().ErrorCode.Should().Be(Code);
            error.As <JsonResult>().Data.As <ErrorViewModel>().ErrorMessage.Should().Be("error message");
        }