From 1067dae34085f482b03489179e60479a08668251 Mon Sep 17 00:00:00 2001 From: Yannic Staudt Date: Tue, 23 Aug 2016 14:53:16 +0200 Subject: [PATCH] Added a test case for #16 related modifications --- NLog.Owin.Logging.Tests/OwinLoggerTest.cs | 12 +++++++++++- NLog.Owin.Logging.Tests/OwinTestApp.cs | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/NLog.Owin.Logging.Tests/OwinLoggerTest.cs b/NLog.Owin.Logging.Tests/OwinLoggerTest.cs index c732c45..f3a4bd1 100644 --- a/NLog.Owin.Logging.Tests/OwinLoggerTest.cs +++ b/NLog.Owin.Logging.Tests/OwinLoggerTest.cs @@ -15,7 +15,7 @@ public class OwinLoggerTest : OwinLoggerTestBase public void InitConfig() { // setup the debug target - _debugTarget = new DebugTarget { Layout = "${level} ${message}" }; + _debugTarget = new DebugTarget { Layout = "${level} EventId:${event-properties:item=EventId} ${message}" }; var loggingConfiguration = new LoggingConfiguration(); @@ -59,5 +59,15 @@ public void TestUnknownEventType() { Assert.ThrowsAsync (() => CallRoute("/invalid")); } + + [Test] + public async Task TestWriteCoreWithEventId() + { + await CallRoute("/eventid"); + + // note: hardcoded event id = 140 in OwinTestApp.cs + Assert.That(_debugTarget.LastMessage, Does.StartWith("Info")); + Assert.That(_debugTarget.LastMessage, Does.Contain("EventId:140")); + } } } \ No newline at end of file diff --git a/NLog.Owin.Logging.Tests/OwinTestApp.cs b/NLog.Owin.Logging.Tests/OwinTestApp.cs index e5cbf8b..87232d9 100644 --- a/NLog.Owin.Logging.Tests/OwinTestApp.cs +++ b/NLog.Owin.Logging.Tests/OwinTestApp.cs @@ -51,6 +51,9 @@ public override async Task Invoke(IOwinContext context) case "/verbose": _logger.WriteVerbose("verbose"); break; + case "/eventid": + _logger.WriteCore(TraceEventType.Information, 140, "test", null, (message, error) => (string)message); + break; case "/invalid": { //write invalid TraceEventType