From f7ada90359395abecc87f49a19d485dec9e62831 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 15 Jun 2026 11:30:15 -0400 Subject: [PATCH] test(integration): harden B8 live assertions (ArchestrAUserToId user_id, bootstrap arrival, split guard) Fix 1 (Important): assert ArchestrAUserToId Ok-path payload carries a non-zero user_id, mirroring the AuthenticateUser pattern. Fix 2 (Important): assert bootstrapBufferedEvents > 0 before the residual return so the "empty NoData bootstrap arrives" claim is verified, not just assumed. Fix 3 (Minor): change SplitLiveItemForBuffered guard from lastDot <= 0 to lastDot < 0 so a leading-dot reference ".TestInt" (lastDot==0) is not mis-handled as undotted. --- .../WorkerLiveMxAccessSmokeTests.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ZB.MOM.WW.MxGateway.IntegrationTests/WorkerLiveMxAccessSmokeTests.cs b/src/ZB.MOM.WW.MxGateway.IntegrationTests/WorkerLiveMxAccessSmokeTests.cs index d2af758..49d4ffd 100644 --- a/src/ZB.MOM.WW.MxGateway.IntegrationTests/WorkerLiveMxAccessSmokeTests.cs +++ b/src/ZB.MOM.WW.MxGateway.IntegrationTests/WorkerLiveMxAccessSmokeTests.cs @@ -660,6 +660,14 @@ public sealed class WorkerLiveMxAccessSmokeTests(ITestOutputHelper output) Assert.True( userToIdReply.ProtocolStatus.Code is ProtocolStatusCode.Ok or ProtocolStatusCode.MxaccessFailure, $"ArchestrAUserToId must surface a real MXAccess outcome, got {userToIdReply.ProtocolStatus.Code}."); + if (userToIdReply.ProtocolStatus.Code == ProtocolStatusCode.Ok) + { + // On the dev rig ArchestrAUserToId with a valid GUID resolves to user_id=1. + // Don't pin the exact id (provider-dependent) — just prove the Ok path carried + // a usable non-zero ArchestrA user id through the reply payload. + Assert.NotNull(userToIdReply.ArchestraUserToId); + Assert.NotEqual(0, userToIdReply.ArchestraUserToId.UserId); + } // Suspend / Activate against the advised item. The dev-rig TestInt item class // may not be suspendable (MXAccess returns 0x80070057 / E_INVALIDARG for a @@ -848,6 +856,13 @@ public sealed class WorkerLiveMxAccessSmokeTests(ITestOutputHelper output) + $"was observed within {IntegrationTestEnvironment.LiveMxAccessEventTimeout}. Live " + "§3.2 multi-sample conversion remains unverified (rig object logic may not drive " + "buffered samples on demand)."); + + // The residual claim ("empty NoData bootstrap arrives and converts without crashing") + // is only meaningful if at least one OnBufferedDataChange event arrived. Assert that + // the buffered subscription registered and the worker's event plumbing fired at all. + Assert.True( + bootstrapBufferedEvents > 0, + "No OnBufferedDataChange event arrived at all after Advise; the buffered subscription may not have registered."); return; } @@ -1416,7 +1431,7 @@ public sealed class WorkerLiveMxAccessSmokeTests(ITestOutputHelper output) private static (string Item, string Context) SplitLiveItemForBuffered(string liveItem) { int lastDot = liveItem.LastIndexOf('.'); - if (lastDot <= 0 || lastDot >= liveItem.Length - 1) + if (lastDot < 0 || lastDot >= liveItem.Length - 1) { return (liveItem, string.Empty); }