InfoWithData() private method

private InfoWithData ( Exception exception, string message, object extraData = null ) : void
exception System.Exception
message string
extraData object
return void
Beispiel #1
0
            public void WorksWithData()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof(int));

                LogMessageEventArgs eventArgs = null;
                log.LogMessage += (sender, e) => eventArgs = e;

                var threadId = ThreadHelper.GetCurrentThreadId();

                log.InfoWithData("log message", new LogData
                {
                    { "ThreadId", threadId }
                });

                Assert.IsNotNull(eventArgs);
                Assert.AreEqual(log, eventArgs.Log);
                Assert.AreEqual(LogEvent.Info, eventArgs.LogEvent);
                Assert.AreEqual("log message", eventArgs.Message);

                var logData = eventArgs.LogData;

                Assert.IsNotNull(logData);
                Assert.IsTrue(ObjectHelper.AreEqual(logData["ThreadId"], threadId));
            }
Beispiel #2
0
            public void WorksWithoutData()
            {
                LogManager.AddDebugListener();
                var log = new Log(typeof(int));

                LogMessageEventArgs eventArgs = null;
                log.LogMessage += (sender, e) => eventArgs = e;

                log.InfoWithData("log message", null);

                Assert.IsNotNull(eventArgs);
                Assert.AreEqual(log, eventArgs.Log);
                Assert.AreEqual(LogEvent.Info, eventArgs.LogEvent);
                Assert.AreEqual("log message", eventArgs.Message);

                var logData = eventArgs.LogData;

                Assert.IsNull(logData);
            }