- Rename tests/NATS.Server.Tests -> tests/NATS.Server.Core.Tests - Update solution file, InternalsVisibleTo, and csproj references - Remove JETSTREAM_INTEGRATION_MATRIX and NATS.NKeys from csproj (moved to JetStream.Tests and Auth.Tests) - Update all namespaces from NATS.Server.Tests.* to NATS.Server.Core.Tests.* - Replace private GetFreePort/ReadUntilAsync helpers with TestUtilities calls - Fix stale namespace in Transport.Tests/NetworkingGoParityTests.cs
51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
namespace NATS.Server.Core.Tests;
|
|
|
|
// Go reference: server/client.go (maxFlushPending, pcd, flush signal coalescing)
|
|
|
|
public class FlushCoalescingTests
|
|
{
|
|
[Fact]
|
|
public void MaxFlushPending_defaults_to_10()
|
|
{
|
|
// Go reference: server/client.go maxFlushPending constant
|
|
NatsClient.MaxFlushPending.ShouldBe(10);
|
|
}
|
|
|
|
[Fact]
|
|
public void ShouldCoalesceFlush_true_when_below_max()
|
|
{
|
|
// When flush signals pending is below MaxFlushPending, coalescing is allowed
|
|
// Go reference: server/client.go fsp < maxFlushPending check
|
|
var pending = 5;
|
|
var shouldCoalesce = pending < NatsClient.MaxFlushPending;
|
|
shouldCoalesce.ShouldBeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void ShouldCoalesceFlush_false_when_at_max()
|
|
{
|
|
// When flush signals pending reaches MaxFlushPending, force flush
|
|
var pending = NatsClient.MaxFlushPending;
|
|
var shouldCoalesce = pending < NatsClient.MaxFlushPending;
|
|
shouldCoalesce.ShouldBeFalse();
|
|
}
|
|
|
|
[Fact]
|
|
public void ShouldCoalesceFlush_false_when_above_max()
|
|
{
|
|
// Above max, definitely don't coalesce
|
|
var pending = NatsClient.MaxFlushPending + 5;
|
|
var shouldCoalesce = pending < NatsClient.MaxFlushPending;
|
|
shouldCoalesce.ShouldBeFalse();
|
|
}
|
|
|
|
[Fact]
|
|
public void FlushCoalescing_constant_matches_go_reference()
|
|
{
|
|
// Go reference: server/client.go maxFlushPending = 10
|
|
// Verify the constant is accessible and correct
|
|
NatsClient.MaxFlushPending.ShouldBeGreaterThan(0);
|
|
NatsClient.MaxFlushPending.ShouldBeLessThanOrEqualTo(100);
|
|
}
|
|
}
|