public void EntityNotFoundWrongExceptionTest() { EntityNotFoundExceptionFilter filter = new EntityNotFoundExceptionFilter(new EmptyModelMetadataProvider()); try { throw new OpenIdConnectProtocolInvalidCHashException("Whoops"); } catch (Exception e) { entityNotFoundExceptionContext.Exception = e; filter.OnException(entityNotFoundExceptionContext); Assert.False(entityNotFoundExceptionContext.ExceptionHandled); } }
public void EntityNotFoundTest() { EntityNotFoundExceptionFilter filter = new EntityNotFoundExceptionFilter(new EmptyModelMetadataProvider()); try { throw new HttpRequestException("404 (not found)"); } catch (Exception e) { entityNotFoundExceptionContext.Exception = e; filter.OnException(entityNotFoundExceptionContext); ViewResult result = (ViewResult)entityNotFoundExceptionContext.Result; Assert.Equal("The requested entity was not found", result.ViewData.Values.First()); Assert.True(entityNotFoundExceptionContext.ExceptionHandled); } }