Path: redb-route/tests/redb.Route.Tests.Kafka/AckModeOptionsTests.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/AckModeOptionsTests.cs
----
using AwesomeAssertions;
using redb.Route.Core;
using redb.Route.Kafka;
namespace redb.Route.Tests.Kafka;
///
/// ackMode, the one option that says when a consumer settles what it received (manual: after the route,
/// auto: on receipt). The connector's former option is refused with its replacement named.
///
public class AckModeOptionsTests
{
private static KafkaEndpointOptions Bind(params (string Key, string Value)[] parameters)
{
var options = new KafkaEndpointOptions();
options.BindFromUri(parameters.ToDictionary(p => p.Key, p => p.Value));
return options;
}
[Fact]
public void The_default_is_manual() => new KafkaEndpointOptions().AckMode.Should().Be(AckMode.Manual);
[Fact]
public void Auto_binds_from_the_uri() => Bind(("ackMode", "auto")).AckMode.Should().Be(AckMode.Auto);
[Fact]
public void The_former_option_is_refused_with_its_replacement()
{
var act = () => Bind(("enableAutoCommit", "false"));
act.Should().Throw().WithMessage("*'enableAutoCommit' is replaced by 'ackMode'*");
}
[Fact]
public void Auto_with_breakOnFirstError_is_refused()
{
var options = Bind(("brokers", "localhost:9092"), ("ackMode", "auto"), ("breakOnFirstError", "true"));
var act = () => options.Validate();
act.Should().Throw().WithMessage("*ackMode=auto*breakOnFirstError*");
}
}