public void DropWhenSizeExceedsMaximum() { // Arrange var batchFormatter = new DefaultBatchFormatter(0); // Act batchFormatter.Format(logEvents, textFormatter, output); // Assert var eventBatch = JsonConvert.DeserializeObject <EventBatchRequestDto>(output.ToString()); eventBatch.Events.Count().ShouldBe(0); }
public void DropLogEventsGivenSizeExceedsMaximum() { // Arrange var batchFormatter = new DefaultBatchFormatter(1); // Act batchFormatter.Format(logEvents, textFormatter, output); // Assert var got = JsonConvert.DeserializeObject <DefaultBatch>(output.ToString()); got.Events.ShouldBeEmpty(); }
public void WriteLogEvents() { // Arrange var batchFormatter = new DefaultBatchFormatter(); // Act batchFormatter.Format(logEvents, textFormatter, output); // Assert var got = JsonConvert.DeserializeObject <DefaultBatch>(output.ToString()); got.Events.Length.ShouldBe(2); got.Events[0].RenderedMessage.ShouldBe("Event 1"); got.Events[1].RenderedMessage.ShouldBe("Event 2"); }
public void FormatFormattedLogEvents() { // Arrange var batchFormatter = new DefaultBatchFormatter(); var formattedLogEvents = logEvents.Select(logEvent => { var formattedLogEvent = new StringWriter(); textFormatter.Format(logEvent, formattedLogEvent); return(formattedLogEvent.ToString()); }); // Act batchFormatter.Format(formattedLogEvents, output); // Assert var eventBatch = JsonConvert.DeserializeObject <EventBatchRequestDto>(output.ToString()); eventBatch.Events.Count().ShouldBe(logEvents.Count()); }
public void WriteFormattedLogEvents() { // Arrange var batchFormatter = new DefaultBatchFormatter(); var formattedLogEvents = logEvents.Select(logEvent => { var formattedLogEvent = new StringWriter(); textFormatter.Format(logEvent, formattedLogEvent); return(formattedLogEvent.ToString()); }); // Act batchFormatter.Format(formattedLogEvents, output); // Assert var got = JsonConvert.DeserializeObject <DefaultBatch>(output.ToString()); got.Events.Length.ShouldBe(2); got.Events[0].RenderedMessage.ShouldBe("Event 1"); got.Events[1].RenderedMessage.ShouldBe("Event 2"); }