public void LogUnhandledException_EventArgsWithHttpUnhandledException_DoesLog() { // Arrange var moduleUnderTest = new TestAspNetExceptionLoggingModule(); object exceptionToLog = new HttpUnhandledException(); var eventArgs = new UnhandledExceptionEventArgs(exceptionToLog, false); using (var scope = new LoggingProviderScope(ScopeOption.AllowOnlyASingleEntryToBeLogged)) { // Act moduleUnderTest.LogUnhandledException(null, eventArgs); // Assert Assert.AreEqual(1, scope.LoggedEntries.Count()); } }
public void LogUnhandledException_EventArgsWithException_LogsCriticalEvent() { // Arrange var expectedSeverity = LoggingEventType.Critical; var moduleUnderTest = new TestAspNetExceptionLoggingModule(); object exceptionToLog = new Exception(); var eventArgs = new UnhandledExceptionEventArgs(exceptionToLog, false); using (var scope = new LoggingProviderScope(ScopeOption.AllowOnlyASingleEntryToBeLogged)) { // Act moduleUnderTest.LogUnhandledException(null, eventArgs); // Assert Assert.AreEqual(expectedSeverity, scope.LoggedEntries.First().Severity); } }
public void Error_WithException_LogsEventWithSeverityOfError() { // Arrange var expectedSeverity = LoggingEventType.Error; var moduleUnderTest = new TestAspNetExceptionLoggingModule(); var context = new HttpApplication(); moduleUnderTest.Init(context); using (var scope = new LoggingProviderScope(ScopeOption.AllowOnlyASingleEntryToBeLogged)) { // Act RaisErrorOnContext(context, new Exception()); // Assert Assert.AreEqual(expectedSeverity, scope.LoggedEntries.First().Severity); } }
public void Error_WithException_LogsException() { // Arrange var moduleUnderTest = new TestAspNetExceptionLoggingModule(); var context = new HttpApplication(); var expectedException = new Exception(); moduleUnderTest.Init(context); using (var scope = new LoggingProviderScope(ScopeOption.AllowOnlyASingleEntryToBeLogged)) { // Act RaisErrorOnContext(context, expectedException); var actualException = scope.LoggedEntries.First().Exception; // Assert Assert.AreEqual(expectedException, actualException); } }
public void Error_WithHttpUnhandledExceptionWithInnerException_LogsInnerException() { // Arrange var moduleUnderTest = new TestAspNetExceptionLoggingModule(); var context = new HttpApplication(); var expectedException = new InvalidOperationException(); var exceptionForError = new HttpUnhandledException("some message", expectedException); moduleUnderTest.Init(context); using (var scope = new LoggingProviderScope(ScopeOption.AllowOnlyASingleEntryToBeLogged)) { // Act RaisErrorOnContext(context, exceptionForError); var actualException = scope.LoggedEntries.First().Exception; // Assert Assert.AreEqual(expectedException, actualException); } }