Skip to content

Commit

Permalink
Added a test case for #16 related modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
pysco68 committed Aug 23, 2016
1 parent cde19e9 commit 1067dae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion NLog.Owin.Logging.Tests/OwinLoggerTest.cs
Expand Up @@ -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();

Expand Down Expand Up @@ -59,5 +59,15 @@ public void TestUnknownEventType()
{
Assert.ThrowsAsync<ArgumentOutOfRangeException> (() => 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"));
}
}
}
3 changes: 3 additions & 0 deletions NLog.Owin.Logging.Tests/OwinTestApp.cs
Expand Up @@ -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
Expand Down

0 comments on commit 1067dae

Please sign in to comment.