예제 #1
0
        public void Initialize_IfAlreadyInitialized_ShouldThrowInvalidOperationException()
        {
            var config = new KafkaConfiguration
            {
                GroupId = "groupId",
                Topics  = new [] { "topic" }
            };
            var consumer = new TestConsumer();

            consumer.Initialize(config);

            var exception = Assert.Throws <InvalidOperationException>(() =>
            {
                consumer.Initialize(config);
            });

            exception.Message.Should().Be("KafkaConsumer is already initialized.");
        }
예제 #2
0
        public void Initialize_GivenNoTopics_ShouldThrowArgumentNullException()
        {
            var config = new KafkaConfiguration
            {
            };
            var consumer = new TestConsumer();

            var exception = Assert.Throws <ArgumentNullException>(() =>
            {
                consumer.Initialize(config);
            });

            exception.Message.Should().Contain(nameof(KafkaConfiguration.Topics));
        }
예제 #3
0
        public void Initialize_GivenNoGroupId_ShouldThrowArgumentException()
        {
            var config = new KafkaConfiguration
            {
                Topics = new[] { "MyTopic" }
            };
            var consumer = new TestConsumer();

            var exception = Assert.Throws <ArgumentException>(() =>
            {
                consumer.Initialize(config);
            });

            exception.Message.Should().Contain("'group.id'");
        }
예제 #4
0
        public void Initialize_GivenNoTopicInTopics_ShouldThrowArgumentNullException()
        {
            var config = new KafkaConfiguration
            {
                Topics = new [] { null as string }
            };
            var consumer = new TestConsumer();

            var exception = Assert.Throws <ArgumentNullException>(() =>
            {
                consumer.Initialize(config);
            });

            exception.Message.Should().Contain("topic");
        }