Path: redb-route/tests/redb.Route.Tests.Amqp/AmqpBatchOptionsTests.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.Amqp/AmqpBatchOptionsTests.cs ---- using redb.Route.Amqp; using redb.Route.Core; namespace redb.Route.Tests.Amqp; /// The AMQP 1.0 batch options on the core contract, and every start refusal of batch mode. public sealed class AmqpBatchOptionsTests { private static AmqpEndpoint Endpoint(string query) => (AmqpEndpoint)new AmqpComponent().CreateEndpoint(EndpointUriParser.Parse($"amqp://orders?host=localhost&{query}")); [Fact] public void Batch_mode_is_off_by_default_and_on_with_batching() { Endpoint("credit=50").EndpointOptions.Batch.Should().BeNull(); var batch = Endpoint("batching=true&credit=50").EndpointOptions.Batch!; batch.MaxMessages.Should().Be(50, "the default batch is the link's credit"); batch.PollTimeout.Should().Be(TimeSpan.FromSeconds(1)); batch.Interval.Should().BeNull(); var tuned = Endpoint("batching=true&maxBatchMessages=20&pollTimeoutMs=250&batchingIntervalMs=4000").EndpointOptions.Batch!; (tuned.MaxMessages, tuned.PollTimeout, tuned.Interval).Should().Be((20, TimeSpan.FromMilliseconds(250), TimeSpan.FromSeconds(4))); } [Theory] [InlineData("maxBatchMessages=10", "*sets maxBatchMessages without batching=true*")] [InlineData("batchingIntervalMs=10", "*sets batchingIntervalMs without batching=true*")] [InlineData("batching=true&credit=10&maxBatchMessages=11", "*maxBatchMessages=11 is larger than credit=10*")] [InlineData("batching=true&replyTo=true", "*batching=true cannot be combined with replyTo=true*")] [InlineData("batching=true&pollTimeoutMs=0", "*pollTimeoutMs must be positive*")] public void Batch_mode_that_cannot_work_fails_at_endpoint_creation(string query, string message) { var act = () => Endpoint(query); act.Should().Throw().WithMessage(message); } [Fact] public void The_builder_writes_the_batch_options() { var uri = AmqpDsl.Address("orders").Batching().MaxBatchMessages(20).PollTimeoutMs(250) .BatchingIntervalMs(4000).DisableReplyTo().Build(); uri.Should().Contain("batching=true").And.Contain("maxBatchMessages=20").And.Contain("pollTimeoutMs=250") .And.Contain("batchingIntervalMs=4000").And.Contain("disableReplyTo=true"); } }