Example #1
0
        public void LogEntry2Event()
        {
            // Make sure cutlure of test is fixed to ensure correct DateTime String
            // conversion and interpretation of expected value below
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            LogEntry entry = TestDataProvider.CreateLogEntry();
            Event    e     = Log4jConverter.Convert(entry);

            Assert.AreEqual("ERROR", e.Level);
            Assert.AreEqual("This is an error message!", e.Message);
            Assert.AreEqual("YALV.Samples.vshost.exe", e.Properties.First(x => x.Name.Equals(Log4jConverter.AppKey)).Value);
            Assert.AreEqual("YALV.Samples.MainWindow", e.LocationInfo.Class);
            Assert.AreEqual(@"c:\Workspace\YalvLib\src\YALV.Samples\MainWindow.xaml.cs", e.LocationInfo.File);
            Assert.AreEqual("tongbong-PC", e.Properties.First(x => x.Name.Equals(Log4jConverter.HostKey)).Value);
            Assert.AreEqual("76", e.LocationInfo.Line);
            Assert.AreEqual("YALV.Samples.LogService", e.Logger);
            Assert.AreEqual("tongbong-PC", e.Properties.First(x => x.Name.Equals(Log4jConverter.MachineKey)).Value);
            Assert.AreEqual("method4", e.LocationInfo.Method);
            Assert.AreEqual("10", e.Thread);
            Assert.AreEqual("System.Exception: Warning Exception!", e.Throwable);
            Assert.AreEqual(new TimeSpan(0, 0, 0, 1).TotalMilliseconds.ToString(), e.Timestamp);
            Assert.AreEqual("tongbong-PC\tongbong", e.Properties.First(x => x.Name.Equals(Log4jConverter.UserKey)).Value);
        }