示例#1
0
        public void CsvLayout_Format_NullTextWriter_ArgumentNullException()
        {
            var fakeLoggingEvent = new LoggingEvent(new LoggingEventData());
            var underTest        = new CsvLayout();

            Assert.Throws <ArgumentNullException>(() => underTest.Format(null, fakeLoggingEvent));
        }
示例#2
0
        public void CsvLayout_Format_EscapeDoubleQuotes_Success()
        {
            // Fake Data
            var fakeFields      = "message";
            var fakeLoggingData = new LoggingEventData()
            {
                Message = "Th\"e \"ans\"wer",
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout(fakeFields);

            underTest.ActivateOptions();
            var result = underTest.Format(fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual("\"Th\"\"e \"\"ans\"\"wer\"\r\n", result);
        }
示例#3
0
        public void CsvLayout_GetFieldValue_NullLoggingEvent_ArgumentNullException()
        {
            // Fake Data
            var fakeFields      = "message";
            var fakeLoggingData = new LoggingEventData()
            {
                Message = "Th\"e \"ans\"wer",
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout(fakeFields);

            underTest.ActivateOptions();
            var result = underTest.Format(fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual("\"Th\"\"e \"\"ans\"\"wer\"\r\n", result);
        }
示例#4
0
        public void CsvLayout_Format_DefaultFields_Success()
        {
            // Fake Data
            var fakeLoggingData = new LoggingEventData()
            {
                TimeStampUtc = new DateTime(2012, 12, 14, 12, 20, 42),
                Level        = Level.Debug,
                Message      = "The answer",
                LoggerName   = "fortytwo"
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.Format(fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual("\"DEBUG\",\"The answer\",\"fortytwo\",\"2012-12-14 07:20:42,000\"\r\n", result);
        }