コード例 #1
0
        public void MvcExceptionMapper_MapException_RemoteEntityNotFoundException()
        {
            // This method tests what happens when a RemoteEntityNotFoundException was thrown
            var mvcExceptionMapper = new MvcExceptionMapper();
            var filterContext      = this.CreateExceptionContext(new RemoteEntityNotFoundException("Testing"));

            mvcExceptionMapper.SetResponse(filterContext);

            Assert.IsNotNull(filterContext.Result);
            Assert.AreEqual((int)HttpStatusCode.NotFound, filterContext.HttpContext.Response.StatusCode);
        }
コード例 #2
0
        public void MvcExceptionMapper_MapException_DemoInvalidOperationException()
        {
            // This method tests what happens when a DemoInvalidOperationException was thrown
            var mvcExceptionMapper = new MvcExceptionMapper();
            var filterContext      = this.CreateExceptionContext(new DemoInvalidOperationException("Testing"));

            mvcExceptionMapper.SetResponse(filterContext);

            Assert.IsNotNull(filterContext.Result);
            Assert.AreEqual((int)HttpStatusCode.BadRequest, filterContext.HttpContext.Response.StatusCode);
        }
コード例 #3
0
        public void MvcExceptionMapper_MapException_SystemException()
        {
            // This method tests what happens when an Exception was thrown
            var mvcExceptionMapper = new MvcExceptionMapper();
            var filterContext      = this.CreateExceptionContext(new Exception("Testing"));

            mvcExceptionMapper.SetResponse(filterContext);

            Assert.IsNotNull(filterContext.Result);
            Assert.AreEqual((int)HttpStatusCode.InternalServerError, filterContext.HttpContext.Response.StatusCode);
        }
コード例 #4
0
 public void MvcExceptionMapper_Constructor()
 {
     // This test verifies that the default constructor works.
     // Note: this test is useless except for code coverage since we are testing the default constructor with no custom logic.
     var mvcExceptionMapper = new MvcExceptionMapper();
 }