コード例 #1
0
        public void FallbackWriter_Write_RethrowsOnSecondaryError()
        {
            var primaryWriter   = new MockLogWriterWithError();
            var secondaryWriter = new MockLogWriterWithError();

            var writer = new FallbackWriter(primaryWriter, secondaryWriter);

            var logEvent = new LogEvent()
            {
                EventName = "Test log message"
            };

            writer.Write(logEvent);
        }
コード例 #2
0
        public void FallbackWriter_Write_FallsbackToSecondaryWriter()
        {
            var primaryWriter   = new MockLogWriterWithError();
            var secondaryList   = new List <LogEvent>();
            var secondaryWriter = new ListLogWriter(secondaryList, 10);

            var writer = new FallbackWriter(primaryWriter, secondaryWriter);

            var logEvent = new LogEvent()
            {
                EventName = "Test log message"
            };

            writer.Write(logEvent);

            Assert.AreEqual(1, secondaryList.Count);
            Assert.AreEqual("Test log message", secondaryList[0].EventName);
        }
コード例 #3
0
        public void FallbackWriter_WriteBatch_RethrowsOnSecondaryError()
        {
            var primaryWriter   = new MockLogWriterWithError();
            var secondaryWriter = new MockLogWriterWithError();

            var writer = new FallbackWriter(primaryWriter, secondaryWriter);

            LogEvent[] logEvents = new LogEvent[2];
            logEvents[0] = new LogEvent()
            {
                EventName = "Test log message"
            };
            logEvents[1] = new LogEvent()
            {
                EventName = "Test log message 2"
            };

            writer.WriteBatch(logEvents);
        }
コード例 #4
0
        public void FallbackWriter_WriteBatch_FallsbackToSecondaryWriter()
        {
            var primaryWriter   = new MockLogWriterWithError();
            var secondaryList   = new List <LogEvent>();
            var secondaryWriter = new ListLogWriter(secondaryList, 10);

            var writer = new FallbackWriter(primaryWriter, secondaryWriter);

            LogEvent[] logEvents = new LogEvent[2];
            logEvents[0] = new LogEvent()
            {
                EventName = "Test log message"
            };
            logEvents[1] = new LogEvent()
            {
                EventName = "Test log message 2"
            };

            writer.WriteBatch(logEvents);

            Assert.AreEqual(2, secondaryList.Count);
            Assert.AreEqual("Test log message", secondaryList[0].EventName);
            Assert.AreEqual("Test log message 2", secondaryList[1].EventName);
        }