public void TestRender() { var logEvent = new LogEvent(DateTimeOffset.UtcNow, LogEventLevel.Debug, null, new MessageTemplate(Enumerable.Empty <MessageTemplateToken>()), new [] { new LogEventProperty("test1", new ScalarValue("answer1")), new LogEventProperty("0", new ScalarValue("this should be missing")), new LogEventProperty("key", new ScalarValue("value")) }); var result = ELKSink.EventToJson(logEvent, new SinkOptions()); var json = JsonConvert.DeserializeObject <dynamic>(result); Console.WriteLine(json); (json["test1"].Value as string).Should().Be("answer1"); bool hasZero = (json["0"] == null); hasZero.Should().Be(true); (json["key"].Value as string).Should().Be("value"); }
public void IncludeDiagnostics_WhenEnabled_DoesNotIncludeDiagnosticsEvent() { var logEvent = new LogEvent(DateTimeOffset.UtcNow, LogEventLevel.Debug, null, new MessageTemplate(Enumerable.Empty <MessageTemplateToken>()), new[] { new LogEventProperty("Field1", new ScalarValue("Value1")), }); var result = new List <string> { ELKSink.EventToJson(logEvent, new SinkOptions()) }; var package = ELKSink.PackageContent(result, 1024, 5); var packageStringTask = package.ReadAsStringAsync(); packageStringTask.Wait(); var packageString = packageStringTask.Result; Assert.IsTrue(result.Count == 1); Assert.IsTrue(!packageString.Contains("LogglyDiagnostics")); }