test: fake time for dashboard snapshot publisher; signal-based waits (mxaccessgw#205)
DashboardSnapshotPublisher takes an optional TimeProvider (default TimeProvider.System) driving the idle poll, the reconnect delay and, via BoundedHubSend, the send timeout. Its tests now run on a fake clock with exact assertions (reconnect gap == delay, 25 idle polls pull nothing, a wedged send is abandoned at the fake send timeout). DashboardSnapshotFeed has no time dependence, so no seam was added; its tests lose the 100 ms sleep and poll loops in favour of CountSignal signals. The Task.Delay(25) poll copies in the alarm-monitor tests and several 5-10 ms poll loops now share TestSupport/Eventually. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
@@ -4,6 +4,7 @@ using ZB.MOM.WW.Auth.Abstractions.ApiKeys;
|
||||
using ZB.MOM.WW.MxGateway.Server.Security.Authentication;
|
||||
|
||||
using LibApiKeyIdentity = ZB.MOM.WW.Auth.Abstractions.ApiKeys.ApiKeyIdentity;
|
||||
using ZB.MOM.WW.MxGateway.Tests.TestSupport;
|
||||
|
||||
namespace ZB.MOM.WW.MxGateway.Tests.Security.Authentication;
|
||||
|
||||
@@ -267,11 +268,7 @@ public sealed class CachingApiKeyVerifierTests
|
||||
|
||||
cache.Compact(1.0);
|
||||
|
||||
DateTime deadline = DateTime.UtcNow + TimeSpan.FromSeconds(5);
|
||||
while (verifier.IndexedCacheKeyCount != 0 && DateTime.UtcNow < deadline)
|
||||
{
|
||||
await Task.Delay(10);
|
||||
}
|
||||
await Eventually.WaitUntilAsync(() => verifier.IndexedCacheKeyCount == 0, TimeSpan.FromSeconds(5));
|
||||
|
||||
Assert.Equal(0, verifier.IndexedCacheKeyCount);
|
||||
Assert.Equal(0, verifier.IndexedKeyIdCount);
|
||||
|
||||
Reference in New Issue
Block a user