Path: redb-route/tests/redb.Route.Tests.Kafka/KafkaComponentTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.Kafka/KafkaComponentTests.cs ---- using redb.Route.Core; using redb.Route.Kafka; namespace redb.Route.Tests.Kafka; public sealed class KafkaComponentTests { private readonly KafkaComponent _sut = new(); [Fact] public void Scheme_ReturnsKafka() { _sut.Scheme.Should().Be("kafka"); } [Fact] public void CreateEndpoint_ValidUri_ReturnsKafkaEndpoint() { var uri = EndpointUriParser.Parse("kafka://my-topic?brokers=localhost:9092&groupId=grp1"); var endpoint = _sut.CreateEndpoint(uri); endpoint.Should().BeOfType(); var kafka = (KafkaEndpoint)endpoint; kafka.TopicName.Should().Be("my-topic"); } [Fact] public void CreateEndpoint_NullUri_Throws() { var act = () => _sut.CreateEndpoint(null!); act.Should().Throw(); } [Fact] public void CreateEndpoint_MissingBrokers_Throws() { var uri = EndpointUriParser.Parse("kafka://my-topic"); var act = () => _sut.CreateEndpoint(uri); act.Should().Throw().WithMessage("*brokers*"); } [Fact] public void CreateEndpoint_WithAllConsumerOptions_ParsesCorrectly() { var uri = EndpointUriParser.Parse( "kafka://events?brokers=b1:9092,b2:9092&groupId=g1&autoOffsetReset=Earliest&batching=true&maxBatchMessages=50&pollTimeoutMs=2000&breakOnFirstError=true&seekTo=beginning&topicIsPattern=true"); var endpoint = (KafkaEndpoint)_sut.CreateEndpoint(uri); endpoint.TopicName.Should().Be("events"); } [Fact] public void CreateEndpoint_WithProducerOptions_ParsesCorrectly() { var uri = EndpointUriParser.Parse( "kafka://orders?brokers=localhost:9092&acks=All&retries=5&recordMetadata=true&key=OrderId&transacted=true"); var endpoint = (KafkaEndpoint)_sut.CreateEndpoint(uri); endpoint.TopicName.Should().Be("orders"); } [Fact] public void CreateEndpoint_WithSecurityOptions_ParsesCorrectly() { var uri = EndpointUriParser.Parse( "kafka://secure-topic?brokers=kafka:9093&securityProtocol=SaslSsl&saslMechanism=Plain&saslUsername=user&saslPassword=pass"); var endpoint = (KafkaEndpoint)_sut.CreateEndpoint(uri); endpoint.TopicName.Should().Be("secure-topic"); } [Theory] [InlineData("maxBatchMessages=10", "maxBatchMessages")] [InlineData("batchingIntervalMs=1000", "batchingIntervalMs")] public void A_batch_option_without_batching_fails_the_start(string option, string named) { var act = () => _sut.CreateEndpoint(EndpointUriParser.Parse($"kafka://orders?brokers=localhost:9092&{option}")); act.Should().Throw().WithMessage($"*kafka://orders*{named}*batching=true*"); } [Theory] [InlineData("maxBatchMessages=0", "maxBatchMessages")] [InlineData("pollTimeoutMs=0", "pollTimeoutMs")] [InlineData("batchingIntervalMs=0", "batchingIntervalMs")] public void A_batch_value_out_of_range_fails_the_start(string option, string named) { var act = () => _sut.CreateEndpoint( EndpointUriParser.Parse($"kafka://orders?brokers=localhost:9092&batching=true&{option}")); act.Should().Throw().WithMessage($"*kafka://orders*{named}*"); } [Fact] public void MaxPollRecords_is_refused_naming_its_replacement() { var act = () => _sut.CreateEndpoint(EndpointUriParser.Parse("kafka://orders?brokers=localhost:9092&maxPollRecords=10")); act.Should().Throw().WithMessage("*maxPollRecords*maxBatchMessages*batching=true*"); } }