상속: LogListener
예제 #1
0
        private static async void TestLevel(string moduleName, EventLevel eventLevel, int expectedId, [CallerMemberName] string testName = null)
        {
            await Task.Run(async() =>
            {
                // register for events of this level and higher (e.g. for warning level events of type warning, error and critical are expected).
                TestLogListener listener = new TestLogListener(eventLevel);

                LogOnEachLevel(moduleName, testName);

                var expectedLogMessage = CreateLogMessage(testName, eventLevel);
                var logEvent           = await WaitForLogEventAsync(listener.LogEvents, expectedLogMessage);

                // check the log event.
                Assert.AreEqual(eventLevel, logEvent.EventLevel);
                Assert.AreEqual(expectedId, logEvent.EventId);
                Assert.IsTrue(logEvent.LogMessage.Contains(expectedLogMessage));
                Assert.AreEqual(moduleName, logEvent.ModluleName);
            });
        }
예제 #2
0
        public void LogEventTest()
        {
            AsyncPump.Run(
                async () =>
                {
                    TestLogListener listener = new TestLogListener(EventLevel.Verbose);

                    string logMessage = "Test the debug log";
                    string moduleName = "LawoTest";

                    Log.Debug(logMessage, moduleName);

                    var logEvent = await WaitForLogEventAsync(listener.LogEvents, logMessage);

                    Assert.AreEqual(EventLevel.Verbose, logEvent.EventLevel);
                    Assert.AreEqual(1, logEvent.EventId);

                    Assert.AreEqual(logMessage, logEvent.LogMessage);
                    Assert.AreEqual(NativeMethods.GetCurrentThreadId(), logEvent.ThreadId);
                    Assert.IsTrue(logEvent.FilePath.Contains("LogTest.cs"));
                    Assert.AreEqual(37, logEvent.LineNumber);
                    Assert.AreEqual(moduleName, logEvent.ModluleName);
                });
        }
예제 #3
0
        public void LogEventTest()
        {
            AsyncPump.Run(
                async() =>
            {
                TestLogListener listener = new TestLogListener(EventLevel.Verbose);

                string logMessage = "Test the debug log";
                string moduleName = "LawoTest";

                Log.Debug(logMessage, moduleName);

                var logEvent = await WaitForLogEventAsync(listener.LogEvents, logMessage);

                Assert.AreEqual(EventLevel.Verbose, logEvent.EventLevel);
                Assert.AreEqual(1, logEvent.EventId);

                Assert.AreEqual(logMessage, logEvent.LogMessage);
                Assert.AreEqual(NativeMethods.GetCurrentThreadId(), logEvent.ThreadId);
                Assert.IsTrue(logEvent.FilePath.Contains("LogTest.cs"));
                Assert.AreEqual(37, logEvent.LineNumber);
                Assert.AreEqual(moduleName, logEvent.ModluleName);
            });
        }
예제 #4
0
        private static async void TestLevel(string moduleName, EventLevel eventLevel, int expectedId, [CallerMemberName] string testName = null)
        {
            await Task.Run(async () =>
            {
                // register for events of this level and higher (e.g. for warning level events of type warning, error and critical are expected).
                TestLogListener listener = new TestLogListener(eventLevel);

                LogOnEachLevel(moduleName, testName);

                var expectedLogMessage = CreateLogMessage(testName, eventLevel);
                var logEvent = await WaitForLogEventAsync(listener.LogEvents, expectedLogMessage);

                // check the log event.
                Assert.AreEqual(eventLevel, logEvent.EventLevel);
                Assert.AreEqual(expectedId, logEvent.EventId);
                Assert.IsTrue(logEvent.LogMessage.Contains(expectedLogMessage));
                Assert.AreEqual(moduleName, logEvent.ModluleName);
            });
        }