コード例 #1
0
        public void TestBasicEventLogging()
        {
            TextWriter      writer = new StringWriter();
            LayoutLoggerXml layout = new LayoutLoggerXml();
            LogObjectData   evt    = CreateBaseEvent();

            layout.Format(writer, null, new LogObject(evt));

            string expected = CreateEventNode("Test message");

            Assert.AreEqual(expected, writer.ToString());
        }
コード例 #2
0
        public void TestBase64EventLogging()
        {
            TextWriter      writer = new StringWriter();
            LayoutLoggerXml layout = new LayoutLoggerXml();
            LogObjectData   evt    = CreateBaseEvent();

            layout.base64EncodeMessage = true;
            layout.Format(writer, null, new LogObject(evt));

            string expected = CreateEventNode("VGVzdCBtZXNzYWdl");

            Assert.AreEqual(expected, writer.ToString());
        }
コード例 #3
0
        public void TestIllegalCharacterMasking()
        {
            TextWriter      writer = new StringWriter();
            LayoutLoggerXml layout = new LayoutLoggerXml();
            LogObjectData   evt    = CreateBaseEvent();

            evt.Message = "This is a masked char->\uFFFF";

            layout.Format(writer, null, new LogObject(evt));

            string expected = CreateEventNode("This is a masked char->?");

            Assert.AreEqual(expected, writer.ToString());
        }
コード例 #4
0
        public void TestCDATAEscaping3()
        {
            TextWriter      writer = new StringWriter();
            LayoutLoggerXml layout = new LayoutLoggerXml();
            LogObjectData   evt    = CreateBaseEvent();

            //The &'s trigger the use of a cdata block
            evt.Message = "]]>&&&&&&&Escape the begining";

            layout.Format(writer, null, new LogObject(evt));

            string expected = CreateEventNode("<![CDATA[]]>]]<![CDATA[>&&&&&&&Escape the begining]]>");

            Assert.AreEqual(expected, writer.ToString());
        }