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);
        }
Пример #2
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();
        }
Пример #3
0
        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());
        }
Пример #5
0
        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");
        }