Move 28 leaf node test files from NATS.Server.Tests into a dedicated NATS.Server.LeafNodes.Tests project. Update namespaces, add InternalsVisibleTo, register in solution file. Replace all Task.Delay polling loops with PollHelper.WaitUntilAsync/YieldForAsync from TestUtilities. Replace private ReadUntilAsync in LeafProtocolTests with SocketTestHelper.ReadUntilAsync. All 281 tests pass.
43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using NATS.Server.LeafNodes;
|
|
using NATS.Server.Subscriptions;
|
|
|
|
namespace NATS.Server.LeafNodes.Tests.LeafNodes;
|
|
|
|
public class LeafSubKeyParityBatch2Tests
|
|
{
|
|
[Fact]
|
|
public void Constants_match_go_leaf_key_and_delay_values()
|
|
{
|
|
LeafSubKey.KeyRoutedSub.ShouldBe("R");
|
|
LeafSubKey.KeyRoutedSubByte.ShouldBe((byte)'R');
|
|
LeafSubKey.KeyRoutedLeafSub.ShouldBe("L");
|
|
LeafSubKey.KeyRoutedLeafSubByte.ShouldBe((byte)'L');
|
|
LeafSubKey.SharedSysAccDelay.ShouldBe(TimeSpan.FromMilliseconds(250));
|
|
LeafSubKey.ConnectProcessTimeout.ShouldBe(TimeSpan.FromSeconds(2));
|
|
}
|
|
|
|
[Fact]
|
|
public void KeyFromSub_matches_go_subject_and_queue_shape()
|
|
{
|
|
LeafSubKey.KeyFromSub(NewSub("foo")).ShouldBe("foo");
|
|
LeafSubKey.KeyFromSub(NewSub("foo", "bar")).ShouldBe("foo bar");
|
|
}
|
|
|
|
[Fact]
|
|
public void KeyFromSubWithOrigin_matches_go_routed_and_leaf_routed_shapes()
|
|
{
|
|
LeafSubKey.KeyFromSubWithOrigin(NewSub("foo")).ShouldBe("R foo");
|
|
LeafSubKey.KeyFromSubWithOrigin(NewSub("foo", "bar")).ShouldBe("R foo bar");
|
|
LeafSubKey.KeyFromSubWithOrigin(NewSub("foo"), "leaf").ShouldBe("L foo leaf");
|
|
LeafSubKey.KeyFromSubWithOrigin(NewSub("foo", "bar"), "leaf").ShouldBe("L foo bar leaf");
|
|
}
|
|
|
|
private static Subscription NewSub(string subject, string? queue = null)
|
|
=> new()
|
|
{
|
|
Subject = subject,
|
|
Queue = queue,
|
|
Sid = Guid.NewGuid().ToString("N"),
|
|
};
|
|
}
|