task6: implement batch38 group E state snapshot and wait queue

This commit is contained in:
Joseph Doherty
2026-03-01 00:39:08 -05:00
parent 9fbcafb2a3
commit df3b44789b
7 changed files with 291 additions and 0 deletions

View File

@@ -48,4 +48,39 @@ public sealed class WaitQueueTests
q.Cycle();
q.Peek()!.Reply.ShouldBe("1b");
}
[Fact]
public void WaitingRequestRecycle_AndWaitQueueFactory_ShouldBehave()
{
var request = new WaitingRequest
{
Subject = "s",
Reply = "r",
N = 0,
D = 1,
MaxBytes = 10,
B = 10,
PriorityGroup = new PriorityGroup { Group = "g", Priority = 1 },
};
request.RecycleIfDone().ShouldBeTrue();
request.Subject.ShouldBe(string.Empty);
request.Reply.ShouldBeNull();
var q = WaitQueue.NewWaitQueue(max: 3);
q.ShouldNotBeNull();
q.IsFull(3).ShouldBeFalse();
}
[Fact]
public void WaitingDeliveryRecycle_ShouldClearState()
{
var wd = new WaitingDelivery { Reply = "r", Sequence = 42, Created = DateTime.UtcNow };
wd.Recycle();
wd.Reply.ShouldBe(string.Empty);
wd.Sequence.ShouldBe(0UL);
wd.Created.ShouldBe(DateTime.UnixEpoch);
}
}