Implement deferred core utility parity APIs/tests and refresh tracking artifacts
This commit is contained in:
@@ -28,6 +28,62 @@ namespace ZB.MOM.NatsNet.Server.Tests.Internal;
|
||||
/// </summary>
|
||||
public sealed class IpQueueTests
|
||||
{
|
||||
[Fact]
|
||||
public void IpqMaxRecycleSize_ShouldAffectQueueConfig()
|
||||
{
|
||||
var q = IpQueue<int>.NewIPQueue("opt-max-recycle", null, IpQueue<int>.IpqMaxRecycleSize(123));
|
||||
q.MaxRecycleSize.ShouldBe(123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IpqSizeCalculation_AndLimitBySize_ShouldEnforceLimit()
|
||||
{
|
||||
var q = IpQueue<byte[]>.NewIPQueue(
|
||||
"opt-size-limit",
|
||||
null,
|
||||
IpQueue<byte[]>.IpqSizeCalculation(e => (ulong)e.Length),
|
||||
IpQueue<byte[]>.IpqLimitBySize(8));
|
||||
|
||||
var (_, err1) = q.Push(new byte[4]);
|
||||
err1.ShouldBeNull();
|
||||
|
||||
var (_, err2) = q.Push(new byte[4]);
|
||||
err2.ShouldBeNull();
|
||||
|
||||
var (_, err3) = q.Push(new byte[1]);
|
||||
err3.ShouldBeSameAs(IpQueueErrors.SizeLimitReached);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IpqLimitByLen_ShouldEnforceLengthLimit()
|
||||
{
|
||||
var q = IpQueue<int>.NewIPQueue("opt-len-limit", null, IpQueue<int>.IpqLimitByLen(2));
|
||||
|
||||
q.Push(1).error.ShouldBeNull();
|
||||
q.Push(2).error.ShouldBeNull();
|
||||
q.Push(3).error.ShouldBeSameAs(IpQueueErrors.LenLimitReached);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NewIPQueue_ShouldApplyOptionsAndRegister()
|
||||
{
|
||||
var registry = new ConcurrentDictionary<string, object>();
|
||||
var q = IpQueue<int>.NewIPQueue(
|
||||
"opt-factory",
|
||||
registry,
|
||||
IpQueue<int>.IpqMaxRecycleSize(55),
|
||||
IpQueue<int>.IpqLimitByLen(1));
|
||||
|
||||
q.MaxRecycleSize.ShouldBe(55);
|
||||
registry.TryGetValue("opt-factory", out var registered).ShouldBeTrue();
|
||||
registered.ShouldBeSameAs(q);
|
||||
|
||||
var (_, err1) = q.Push(1);
|
||||
err1.ShouldBeNull();
|
||||
var (_, err2) = q.Push(2);
|
||||
err2.ShouldBeSameAs(IpQueueErrors.LenLimitReached);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Basic_ShouldInitialiseCorrectly()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user