public void OnExceptionTest_NullLogger_NoRethrow() { //We don't want to bubble up an exception if no logger is configured. var attr = new LoggingHandleErrorAttribute(null); attr.OnException(filterContext); }
public void OnExceptionTest_IfExceptionHandled_LogsError() { var attr = new LoggingHandleErrorAttribute(mockLogger.Object); attr.OnException(filterContext); mockLogger.Verify(p => p.Error(It.IsAny<Exception>()), Times.Exactly(1)); }
public void OnExceptionTest_IfExceptionHandled_SetsViewBag() { var attr = new LoggingHandleErrorAttribute(mockLogger.Object); attr.OnException(filterContext); ViewResult result = filterContext.Result as ViewResult; Assert.IsInstanceOfType(result.ViewBag.ErrorMessage, typeof(string)); Assert.IsInstanceOfType(result.ViewBag.CorrelationId, typeof(Guid)); }
public void OnExceptionTest_NullConstructor_Throws() { var attr = new LoggingHandleErrorAttribute(mockLogger.Object); attr.OnException(null); }