public void KafkaWithFallback_ShouldThrowsException_WhenFormatterIsNull()
        {
            // Arrange
            var sinkConfiguration = new LoggerConfiguration().WriteTo;

            // Act + Assert
            Assert.Throws <ArgumentNullException>("formatter",
                                                  () => sinkConfiguration.Kafka(null, null, null, TimeSpan.Zero));
        }
        public void KafkaWithoutFallback_ShouldThrowsException_WhenKafkaOptionsIsNull()
        {
            // Arrange
            var sinkConfiguration = new LoggerConfiguration().WriteTo;
            var formatter         = new JsonFormatter();

            // Act + Assert
            Assert.Throws <ArgumentNullException>("kafka",
                                                  () => sinkConfiguration.Kafka(formatter, null));
        }
        public void KafkaWithFallback_ShouldThrowsException_WhenFallbackIsNull()
        {
            // Arrange
            var sinkConfiguration = new LoggerConfiguration().WriteTo;
            var formatter         = new JsonFormatter();
            var kafkaOptions      = new KafkaOptions(new List <string> {
                "broker"
            }, "topicName");

            // Act + Assert
            Assert.Throws <ArgumentNullException>("fallback",
                                                  () => sinkConfiguration.Kafka(formatter, kafkaOptions, null, TimeSpan.Zero));
        }
        public void KafkaWithFallback_ShouldThrowsException_WhenFallbackTimeIsNonPositive(TimeSpan value)
        {
            // Arrange
            var sinkConfiguration = new LoggerConfiguration().WriteTo;
            var formatter         = new JsonFormatter();
            var kafkaOptions      = new KafkaOptions(new List <string> {
                "broker"
            }, "topicName");
            var fallbackSink = Mock.Of <ILogEventSink>();

            // Act + Assert
            Assert.Throws <ArgumentOutOfRangeException>("fallbackTime",
                                                        () => sinkConfiguration.Kafka(formatter, kafkaOptions, fallbackSink, value));
        }
        public void KafkaWithoutFallback_ShouldNotThrowsException_WhenAllOptionsAreValid()
        {
            // Arrange
            var sinkConfiguration = new LoggerConfiguration().WriteTo;
            var formatter         = new JsonFormatter();
            var kafkaOptions      = new KafkaOptions(new List <string> {
                "broker"
            }, "topicName");
            var batchOptions = new BatchOptions();

            // Act
            var sink = sinkConfiguration.Kafka(formatter, kafkaOptions, batchOptions);

            // Assert
            Assert.NotNull(sink);
        }
        public void KafkaWithFallback_ShouldNotThrowsException_WhenOptionsAreValid()
        {
            // Arrange
            var sinkConfiguration = new LoggerConfiguration().WriteTo;
            var formatter         = new JsonFormatter();
            var kafkaOptions      = new KafkaOptions(new List <string> {
                "broker"
            }, "topicName");
            var fallbackSink = Mock.Of <ILogEventSink>();
            var fallbackTime = TimeSpan.FromMinutes(1);

            // Act
            var sink = sinkConfiguration.Kafka(formatter, kafkaOptions, fallbackSink, fallbackTime);

            // Assert
            Assert.NotNull(sink);
        }