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()); }
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()); }
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()); }
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()); }