public void NoConnectionWrongExceptionTest() { NoConnectionExceptionFilter filter = new NoConnectionExceptionFilter(new EmptyModelMetadataProvider()); try { throw new SecurityTokenEncryptionKeyNotFoundException(); } catch (Exception e) { noConnectionExceptionContext.Exception = e; filter.OnException(noConnectionExceptionContext); Assert.False(noConnectionExceptionContext.ExceptionHandled); } }
public void NoConnectionTest() { NoConnectionExceptionFilter filter = new NoConnectionExceptionFilter(new EmptyModelMetadataProvider()); try { throw new AggregateException(); } catch (Exception e) { noConnectionExceptionContext.Exception = e; filter.OnException(noConnectionExceptionContext); ViewResult result = (ViewResult)noConnectionExceptionContext.Result; Assert.Equal( "Unfortunately, the application was unable to connect to the server, please try again later.", result.ViewData.Values.Last()); Assert.True(noConnectionExceptionContext.ExceptionHandled); } }