Path: redb-route/tests/redb.Route.Tests.Sqs/SqsBatchOptionsTests.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.Sqs/SqsBatchOptionsTests.cs
----
using redb.Route.Core;
using redb.Route.Sqs;
namespace redb.Route.Tests.Sqs;
/// SQS batch options: resolved when the endpoint is created; each configuration that cannot work refused.
public sealed class SqsBatchOptionsTests
{
private static SqsEndpoint Create(string query)
=> (SqsEndpoint)new SqsComponent().CreateEndpoint(EndpointUriParser.Parse($"sqs://orders?region=us-east-1&accessKey=test&secretKey=test&{query}"));
[Theory]
[InlineData("maxBatchMessages=5", "maxBatchMessages")]
[InlineData("batchingIntervalMs=1000", "batchingIntervalMs")]
public void A_batch_option_without_batching_is_refused(string query, string named)
{
var act = () => Create(query);
act.Should().Throw().WithMessage($"*sqs://orders*{named}*batching=true*");
}
[Theory]
[InlineData("maxBatchMessages=0", "maxBatchMessages")]
[InlineData("pollTimeoutMs=0", "pollTimeoutMs")]
[InlineData("batchingIntervalMs=0", "batchingIntervalMs")]
public void A_value_out_of_range_is_refused(string query, string named)
{
var act = () => Create($"batching=true&{query}");
act.Should().Throw().WithMessage($"*{named}*");
}
[Fact]
public void Batching_with_extendMessageVisibility_is_refused()
{
var act = () => Create("batching=true&visibilityTimeout=30&extendMessageVisibility=true");
act.Should().Throw().WithMessage("*batching=true*extendMessageVisibility*visibilityTimeout*");
}
[Fact]
public void Batching_defaults_to_a_batch_of_one_receive()
{
var options = new SqsEndpointOptions { Batching = true };
options.ResolveBatch("sqs://orders");
options.Batch!.MaxMessages.Should().Be(10);
options.Batch.PollTimeout.Should().Be(TimeSpan.FromSeconds(1));
options.Batch.Interval.Should().BeNull();
}
[Fact]
public void A_batch_may_be_larger_than_one_receive()
{
var options = new SqsEndpointOptions { Batching = true, MaxBatchMessages = 25, BatchingIntervalMs = 5000 };
options.ResolveBatch("sqs://orders");
options.Batch!.MaxMessages.Should().Be(25);
options.Batch.Interval.Should().Be(TimeSpan.FromSeconds(5));
}
[Fact]
public void Without_batching_there_are_no_batch_options()
{
var options = new SqsEndpointOptions();
options.ResolveBatch("sqs://orders");
options.Batch.Should().BeNull();
}
[Theory]
[InlineData("enableBatch=true")]
[InlineData("batchMaxMessages=5")]
public void The_removed_producer_batch_options_are_unknown(string query)
{
var act = () => Create(query);
act.Should().Throw().WithMessage(query.Split('=')[0] is var name ? $"*{name}*" : "*");
}
}