Path: redb-route/tests/redb.Route.Tests.RabbitMQ/RabbitMQComponentTests.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.RabbitMQ/RabbitMQComponentTests.cs ---- using redb.Route.Core; using redb.Route.RabbitMQ; namespace redb.Route.Tests.RabbitMQ; public sealed class RabbitMQComponentTests { private readonly RabbitMQComponent _sut = new(); [Fact] public void Scheme_ReturnsRabbitMQ() { _sut.Scheme.Should().Be("rabbitmq"); } [Fact] public void CreateEndpoint_ValidUri_ReturnsRabbitMQEndpoint() { var uri = EndpointUriParser.Parse("rabbitmq://my-queue?host=localhost"); var endpoint = _sut.CreateEndpoint(uri); endpoint.Should().BeOfType(); var rmq = (RabbitMQEndpoint)endpoint; rmq.QueueName.Should().Be("my-queue"); } [Fact] public void CreateEndpoint_NullUri_Throws() { var act = () => _sut.CreateEndpoint(null!); act.Should().Throw(); } [Fact] public void CreateEndpoint_WithExchangeAndRouting_ParsesCorrectly() { var uri = EndpointUriParser.Parse( "rabbitmq://orders?host=rabbit:5672&exchange=ex1&exchangeType=topic&routingKey=order.*&durable=true&declare=true"); var endpoint = (RabbitMQEndpoint)_sut.CreateEndpoint(uri); endpoint.QueueName.Should().Be("orders"); } [Fact] public void CreateEndpoint_WithConsumerOptions_ParsesCorrectly() { var uri = EndpointUriParser.Parse( "rabbitmq://q1?host=localhost&concurrentConsumers=4&prefetchCount=20&transacted=true"); var endpoint = (RabbitMQEndpoint)_sut.CreateEndpoint(uri); endpoint.QueueName.Should().Be("q1"); } [Fact] public void CreateEndpoint_WithRpcOptions_ParsesCorrectly() { var uri = EndpointUriParser.Parse("rabbitmq://rpc-queue?host=localhost&replyTo=true&timeout=30"); var endpoint = (RabbitMQEndpoint)_sut.CreateEndpoint(uri); endpoint.QueueName.Should().Be("rpc-queue"); } [Fact] public void CreateEndpoint_EmptyQueue_AllowsAutoGenerated() { // Empty path → auto-generated exclusive queue (valid scenario) var uri = EndpointUriParser.Parse("rabbitmq://?host=localhost&exchange=my-exchange"); var endpoint = (RabbitMQEndpoint)_sut.CreateEndpoint(uri); endpoint.QueueName.Should().BeEmpty(); } [Theory] [InlineData("host=other-broker", "host")] [InlineData("port=5671", "port")] [InlineData("username=bob&password=x", "username")] [InlineData("VirtualHost=/other", "VirtualHost")] [InlineData("ssl=true", "ssl")] [InlineData("heartbeat=10", "heartbeat")] [InlineData("clientName=svc", "clientName")] public void A_named_factory_with_connection_parameters_on_the_uri_is_refused(string connectionParams, string named) { // The factory is the whole connection, as in Camel; a URI parameter next to it would be ignored, so it is refused // instead of sending the route to another broker than the one written. var uri = EndpointUriParser.Parse($"rabbitmq://orders?connectionFactory=prod&{connectionParams}"); var act = () => _sut.CreateEndpoint(uri); act.Should().Throw() .Which.Message.Should().Contain("'prod'").And.Contain(named); } [Fact] public void A_named_factory_with_only_routing_parameters_is_accepted() { var uri = EndpointUriParser.Parse("rabbitmq://orders?connectionFactory=prod&exchange=ex&routingKey=k&prefetchCount=5"); var act = () => _sut.CreateEndpoint(uri); act.Should().NotThrow(); } }