Path: redb-route/tests/redb.Route.Tests.Sql/Batch/BatchOptionsValidationTests.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.Sql/Batch/BatchOptionsValidationTests.cs
----
using redb.Route.Core;
using redb.Route.Tests.Sql.Batch.Fakes;
using redb.Route.Tests.Sql.E2E.Infrastructure;
namespace redb.Route.Tests.Sql.Batch;
///
/// Options that cannot take effect fail when the endpoint is created (decision 5-a, connector only). Today a
/// ${...} value for a numeric option is silently dropped and the option keeps its default — for
/// batchSize that turns batching off and sends the whole list to a single statement.
///
public sealed class BatchOptionsValidationTests
{
[Theory]
[InlineData("batchSize")]
[InlineData("commandTimeout")]
[InlineData("maxMessagesPerPoll")]
public async Task KnownOption_UnconvertibleValue_FailsAtEndpointCreation(string option)
{
await using var context = new RouteContext();
var act = () => SqlEndpointHarness.CreateEndpoint(context, new FixedConnectionFactory(new FakeBatchConnection()),
"INSERT INTO t (id) VALUES (:#id)", new() { [option] = "${header.n}" });
act.Should().Throw().WithMessage($"*{option}*");
}
[Fact]
public async Task Batch_NegativeBatchSize_FailsAtEndpointCreation()
{
await using var context = new RouteContext();
var act = () => SqlEndpointHarness.CreateEndpoint(context, new FixedConnectionFactory(new FakeBatchConnection()),
"INSERT INTO t (id) VALUES (:#id)", new() { ["batchSize"] = "-1" });
act.Should().Throw().WithMessage("*BatchSize*");
}
}