public void LogSimpleType() { var options = new LogDNAOptions("key", LogLevel.Critical); var mockClient = new Mock <IApiClient>(); mockClient.Setup(x => x.AddLine(It.IsAny <LogLine>())).Callback <LogLine>(line => { var detail = GetDetail(line.Content); Assert.Equal("name", line.Filename); Assert.Equal("message", detail.Message); Assert.Equal("CRITICAL", detail.Level); Assert.Null(detail.Value); }); var client = mockClient.Object; var logger = new LogDNALogger("name", client, options); logger.Log( LogLevel.Critical, new EventId(), new FormattedLogValues("message", null), null, null ); }
public void LogWrapper() { var options = new LogDNAOptions("key", LogLevel.Critical); var mockClient = new Mock <IApiClient>(); mockClient.Setup(x => x.AddLine(It.IsAny <LogLine>())).Callback <LogLine>(line => { var detail = GetDetail(line.Content); Assert.Equal("name", line.Filename); Assert.Equal("message", detail.Message); Assert.Equal("CRITICAL", detail.Level); Assert.NotNull(detail.Value); var value = ((JObject)detail.Value).ToObject <KeyValuePair <string, string> >(); Assert.Equal("key", value.Key); Assert.Equal("value", value.Value); }); var client = mockClient.Object; var logger = new LogDNALogger("name", client, options); logger.Log( LogLevel.Critical, new EventId(), new FormattedLogValues("message", new Wrapper(new KeyValuePair <string, string>("key", "value"))), null, null ); }