public void Log_WithFailingImplementationAndConfiguredFallbackProvider_LogsOriginalFailureToFallbackProvider() { // Arrange var failingProvider = new ThrowingLoggingProvider(); failingProvider.Initialize("Failing provider name", new NameValueCollection()); var fallbackProvider = new MemoryLoggingProvider(); failingProvider.FallbackProvider = fallbackProvider; failingProvider.ExceptionToThrowFromLogInternal = new InvalidOperationException(); var expectedEntry = new LogEntry(LoggingEventType.Error, "The event could not be logged with provider 'Failing provider name'.", "CuttingEdge.Logging.Tests.Unit.LoggingProviderBaseTests+ThrowingLoggingProvider", failingProvider.ExceptionToThrowFromLogInternal); // Act failingProvider.Log("Valid message"); // Assert var loggedEntry = fallbackProvider.GetLoggedEntries().Last(); AssertHelper.LogEntriesAreEqual(expectedEntry, loggedEntry); }
public void Log_WithFailingImplementationButWithoutConfiguredFallbackProvider_BubblesThrownException() { // Arrange var provider = new ThrowingLoggingProvider(); provider.ExceptionToThrowFromLogInternal = new InvalidOperationException(); // Act provider.Log("Valid message"); }
public void Log_WithFailingImplementationAndConfiguredFallbackProvider_LogsEventToFallbackProvider() { // Arrange var failingProvider = new ThrowingLoggingProvider(); var fallbackProvider = new MemoryLoggingProvider(); failingProvider.FallbackProvider = fallbackProvider; failingProvider.ExceptionToThrowFromLogInternal = new InvalidOperationException(); var entryToLog = new LogEntry(LoggingEventType.Critical, "Valid message", null, null); // Act ((ILogger)failingProvider).Log(entryToLog); // Assert var loggedEntry = fallbackProvider.GetLoggedEntries().First(); Assert.AreEqual(entryToLog, loggedEntry); }