コード例 #1
0
        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");
        }
コード例 #4
0
        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");
        }