public void BufferProxy_RemainingMessagesAreFlushedWhenBufferProxyIsDisposed()
        {
            LogConfiguration configuration = new LogConfiguration();
            BufferProxy proxy = new BufferProxy { BufferSize = 3 };
            TestSink sink = new TestSink();
            proxy.Sinks.Add(sink);
            configuration.Sinks.Add(proxy);
            LogKernel kernel = new LogKernel(configuration);
            ILogger logger = kernel.GetLogger();

            Assert.AreEqual(0, sink.MessagesWritten);
            logger.Write(LogLevel.Information, "Hello World!");
            logger.Write(LogLevel.Information, "Hello World Again!");
            Assert.AreEqual(0, sink.MessagesWritten);
            configuration.Dispose();
            Assert.AreEqual(2, sink.MessagesWritten);
        }
        public void LogSinkProxy_UnhandledExceptionsInLogSinkProxyAreHandledAndWrittenToInternalLogWhenWritingMoreThanOneMessage_LogSinkGotNoName()
        {
            // This test is using the buffer proxy to buffer up messages and
            // indirectly use the LogSink.Write(ILogEntry[]) overload on the sink.

            LogConfiguration configuration = new LogConfiguration();
            configuration.InternalLogger.Enabled = true;
            BufferProxy funnelProxy = new BufferProxy() { BufferSize = 0 };
            funnelProxy.Sinks.Add(new ThrowSink(() => new InvalidOperationException("Hello World!")));
            configuration.Sinks.Add(funnelProxy);
            LogKernel kernel = new LogKernel(configuration);
            ILogger logger = kernel.GetLogger();

            string expected = "[BLACKBOX] An unnamed sink of type 'BlackBox.UnitTests.Tests.LogSinkTests+ThrowSink' threw an exception. Hello World!";
            using (StringTraceListenerScope scope = new StringTraceListenerScope())
            {
                logger.Write(LogLevel.Information, "TestMessage");
                Assert.AreEqual(expected, scope.Listener.Messages[0]);
            }
        }