Beispiel #1
0
        public void DropWhenSizeExceedsMaximum()
        {
            // Arrange
            var batchFormatter = new ArrayBatchFormatter(0);

            // Act
            batchFormatter.Format(logEvents, textFormatter, output);

            // Assert
            var eventBatch = JsonConvert.DeserializeObject <EventDto[]>(output.ToString());

            eventBatch.Count().ShouldBe(0);
        }
        public void DropLogEventsGivenSizeExceedsMaximum()
        {
            // Arrange
            var batchFormatter = new ArrayBatchFormatter(1);

            // Act
            batchFormatter.Format(logEvents, textFormatter, output);

            // Assert
            var actual = JsonConvert.DeserializeObject <NormalTextLogEvent[]>(output.ToString());

            actual.ShouldBeEmpty();
        }
Beispiel #3
0
        public void FormatLogEvents()
        {
            // Arrange
            var batchFormatter = new ArrayBatchFormatter();

            // Act
            batchFormatter.Format(logEvents, textFormatter, output);

            // Assert
            var eventBatch = JsonConvert.DeserializeObject <EventDto[]>(output.ToString());

            eventBatch.Count().ShouldBe(logEvents.Count());
        }
        public void HandleEmptySequenceOfLogEvents()
        {
            // Arrange
            var batchFormatter           = new ArrayBatchFormatter();
            var emptySequenceOfLogEvents = Enumerable.Empty <LogEvent>();

            // Act
            batchFormatter.Format(emptySequenceOfLogEvents, textFormatter, output);

            // Assert
            var got = output.ToString();

            got.ShouldBeEmpty();
        }
        public void WriteLogEvents()
        {
            // Arrange
            var batchFormatter = new ArrayBatchFormatter();

            // Act
            batchFormatter.Format(logEvents, textFormatter, output);

            // Assert
            var actual = JsonConvert.DeserializeObject <NormalTextLogEvent[]>(output.ToString());

            actual.Length.ShouldBe(2);
            actual[0].RenderedMessage.ShouldBe("Event 1");
            actual[1].RenderedMessage.ShouldBe("Event 2");
        }
Beispiel #6
0
        public void FormatFormattedLogEvents()
        {
            // Arrange
            var batchFormatter     = new ArrayBatchFormatter();
            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 <EventDto[]>(output.ToString());

            eventBatch.Count().ShouldBe(logEvents.Count());
        }
        public void WriteFormattedLogEvents()
        {
            // Arrange
            var batchFormatter = new ArrayBatchFormatter();

            var formattedLogEvents = logEvents.Select(logEvent =>
            {
                var formattedLogEvent = new StringWriter();
                textFormatter.Format(logEvent, formattedLogEvent);
                return(formattedLogEvent.ToString());
            });

            // Act
            batchFormatter.Format(formattedLogEvents, output);

            // Assert
            var actual = JsonConvert.DeserializeObject <NormalTextLogEvent[]>(output.ToString());

            actual.Length.ShouldBe(2);
            actual[0].RenderedMessage.ShouldBe("Event 1");
            actual[1].RenderedMessage.ShouldBe("Event 2");
        }