public void PackageContentsTest() { var jsons = new[] { "{'fruit': 'orange'}", "{'fruit': 'apple'}", "{'fruit': 'banana'}", }.ToList(); var noDiagContent = ELKSink.PackageContent(jsons, Encoding.UTF8.GetByteCount(string.Join("\n", jsons)), 0, false); var stringContent = ELKSink.PackageContent(jsons, Encoding.UTF8.GetByteCount(string.Join("\n", jsons)), 0, true); stringContent.Should().NotBeNull(); noDiagContent.Should().NotBeNull(); var result = stringContent.ReadAsStringAsync().GetAwaiter().GetResult(); var resultNoDiag = noDiagContent.ReadAsStringAsync().GetAwaiter().GetResult(); result.Split('\n').Count().Should().Be(4); resultNoDiag.Split('\n').Count().Should().Be(3); }
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")); }