From b47a168a2c6f50b458fd5ba5b3e5db4eb6c21d0b Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 9 Nov 2026 13:09:33 -0500 Subject: [PATCH] test: assert the result of timed SemaphoreSlim.WaitAsync in GatewaySessionTests (mxaccessgw#221) The two start-gate waits in GatewaySessionTests ignored the bool from WaitAsync(timeout), so a wait that timed out let the task run on un-synchronised and the race test could pass without racing. Both now Assert.True the result. Every other timed semaphore wait in the Tests project was already checked (the #205 lease helper, the new CountSignal) or is token-only. Mutation check: with Release(n-1) and a 200 ms gate wait, the original code passes (vacuous) while the fixed code fails with "Timed out at the start gate." Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV --- .../Gateway/Sessions/GatewaySessionTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ZB.MOM.WW.MxGateway.Tests/Gateway/Sessions/GatewaySessionTests.cs b/src/ZB.MOM.WW.MxGateway.Tests/Gateway/Sessions/GatewaySessionTests.cs index f9e5b97b..587636f2 100644 --- a/src/ZB.MOM.WW.MxGateway.Tests/Gateway/Sessions/GatewaySessionTests.cs +++ b/src/ZB.MOM.WW.MxGateway.Tests/Gateway/Sessions/GatewaySessionTests.cs @@ -267,7 +267,7 @@ public sealed class GatewaySessionTests { // All threads wait at the gate so they start as simultaneously // as the scheduler allows, maximising the race window. - await gate.WaitAsync(testTimeout); + Assert.True(await gate.WaitAsync(testTimeout), "Timed out at the start gate."); lease.Dispose(); }); } @@ -423,7 +423,7 @@ public sealed class GatewaySessionTests int index = t; tasks[index] = Task.Run(async () => { - await gate.WaitAsync(testTimeout); + Assert.True(await gate.WaitAsync(testTimeout), "Timed out at the start gate."); try { IEventSubscriberLease lease = session.AttachEventSubscriber(maxSubscribers: Cap);