test(batch18): port behavioral batch-18 tests

This commit is contained in:
Joseph Doherty
2026-02-28 19:29:19 -05:00
parent 108d06dd57
commit eb05308b5a
4 changed files with 66 additions and 0 deletions

View File

@@ -7,6 +7,22 @@ namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
public sealed partial class RouteHandlerTests
{
[Fact] // T:2819
public async Task RouteIPResolutionAndRouteToSelf_ShouldSucceed()
{
var (server, err) = NatsServer.NewServer(new ServerOptions());
err.ShouldBeNull();
server.ShouldNotBeNull();
var resolver = new FixedResolver(["127.0.0.1", "other.host.in.cluster"]);
var excluded = new HashSet<string>(StringComparer.Ordinal) { "127.0.0.1:1234" };
var (address, resolveErr) = await server!.GetRandomIP(resolver, "routehost:1234", excluded);
resolveErr.ShouldBeNull();
address.ShouldBe("other.host.in.cluster:1234");
}
[Fact]
public void NumRemotesInternal_WhenRoutesExist_ReturnsCount()
{
@@ -122,4 +138,10 @@ public sealed partial class RouteHandlerTests
route.FlushOutbound().ShouldBeTrue();
route.Flags.IsSet(ClientFlags.IsSlowConsumer).ShouldBeFalse();
}
private sealed class FixedResolver(string[] hosts) : INetResolver
{
public Task<string[]> LookupHostAsync(string host, CancellationToken ct = default)
=> Task.FromResult(hosts);
}
}