public void IfWriteAsyncThrowsWhileAwaitingHandleErrorIsCalled() { var logProcessor = new FireAndForgetLogProcessor(); var logProvider = new FakeLogProvider(); var logEntry = new LogEntry(); Error capturedError = null; var waitHandle = new AutoResetEvent(false); IErrorHandler errorHandler = DelegateErrorHandler.New(error => { capturedError = error; waitHandle.Set(); }); logProcessor.Unlock().SendToLogProvider(logProvider, logEntry, errorHandler, 1); waitHandle.WaitOne(10000).Should().BeTrue(); capturedError.Should().NotBeNull(); capturedError.Exception.Message.Should().Be("oh, no."); capturedError.LogProvider.Should().BeSameAs(logProvider); capturedError.LogEntry.Should().BeSameAs(logEntry); capturedError.FailureCount.Should().Be(2); }
public void IfWriteAsyncThrowsWhileAwaitingHandleErrorIsCalled() { var logProcessor = new BackgroundLogProcessor(); var logProvider = new FakeLogProvider(); var logEntry = new LogEntry(); Error capturedError = null; IErrorHandler errorHandler = DelegateErrorHandler.New(error => { capturedError = error; }); logProcessor.Unlock().SendToLogProvider(logProvider, logEntry, errorHandler, 1); logProcessor.Dispose(); capturedError.Should().NotBeNull(); capturedError.Exception.Message.Should().Be("oh, no."); capturedError.LogProvider.Should().BeSameAs(logProvider); capturedError.LogEntry.Should().BeSameAs(logEntry); capturedError.FailureCount.Should().Be(2); }