public void PackageContentsTest() { var jsons = new[] { "{'fruit': 'orange'}", "{'fruit': 'apple'}", "{'fruit': 'banana'}", }.ToList(); var noDiagContent = LogglySink.PackageContent(jsons, Encoding.UTF8.GetByteCount(string.Join("\n", jsons)), 0, false); var stringContent = LogglySink.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_WhenDisbled_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> { LogglySink.EventToJson(logEvent) }; var package = LogglySink.PackageContent(result, 1024, 5); var packageStringTask = package.ReadAsStringAsync(); packageStringTask.Wait(); var packageString = packageStringTask.Result; (result.Count == 1).Should().BeTrue(); packageString.Contains("LogglyDiagnostics").Should().BeFalse(); }
public void PackageContentsTest() { var jsons = new[] { "{'fruit': 'orange'}", "{'fruit': 'apple'}", "{'fruit': 'banana'}", }.ToList(); //changing to remove diagnostics parameter to show that the default version is false, and that this test ensures backwards API compatibility. Don't add it back w/o cutting major version! var noDiagContent = LogglySink.PackageContent(jsons, Encoding.UTF8.GetByteCount(string.Join("\n", jsons)), 0); var stringContent = LogglySink.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').Length.Should().Be(4); resultNoDiag.Split('\n').Length.Should().Be(3); }