From 964b40dcbc91135e2066d4d96febcad016b212e3 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 18 May 2026 23:19:32 -0400 Subject: [PATCH] Fix stale WorkerProjectReferenceTests MXAccess-interop assertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MxAccessInteropReference_ExistsOnlyInWorkerProject asserted the MXAccess COM interop was referenced only by MxGateway.Worker. The worker test project now legitimately references ArchestrA.MxAccess and Interop.WNWRAPCONSUMERLib so it can exercise the COM-facing worker code (WnWrapAlarmConsumer, the alarm tests). Renamed to ..._ExistsOnlyInWorkerAndWorkerTestProjects, updated the assertion to expect both projects, and made it order-independent. The architecture invariant the test protects — the gateway/contracts never reference MXAccess COM — still holds. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../WorkerProjectReferenceTests.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/MxGateway.Worker.Tests/ProjectStructure/WorkerProjectReferenceTests.cs b/src/MxGateway.Worker.Tests/ProjectStructure/WorkerProjectReferenceTests.cs index fb0dc1a..1e9910f 100644 --- a/src/MxGateway.Worker.Tests/ProjectStructure/WorkerProjectReferenceTests.cs +++ b/src/MxGateway.Worker.Tests/ProjectStructure/WorkerProjectReferenceTests.cs @@ -29,9 +29,16 @@ public sealed class WorkerProjectReferenceTests Assert.Equal("x86", ElementValue(project, "PlatformTarget")); } - /// Verifies that MXAccess interop reference exists only in the worker project. + /// + /// Verifies that the MXAccess COM interop is referenced only by the + /// worker project and its test project — never by the gateway server + /// or the contracts project. The gateway must never load MXAccess COM + /// directly (see gateway.md); the worker test project + /// legitimately references the interop so it can exercise the + /// COM-facing worker code (e.g. WnWrapAlarmConsumer). + /// [Fact] - public void MxAccessInteropReference_ExistsOnlyInWorkerProject() + public void MxAccessInteropReference_ExistsOnlyInWorkerAndWorkerTestProjects() { DirectoryInfo repositoryRoot = FindRepositoryRoot(); string[] projectFiles = Directory.GetFiles(repositoryRoot.FullName, "*.csproj", SearchOption.AllDirectories) @@ -42,9 +49,12 @@ public sealed class WorkerProjectReferenceTests IReadOnlyList projectsWithMxAccessReference = projectFiles .Where(ProjectReferencesMxAccess) .Select(path => Path.GetFileNameWithoutExtension(path)) + .OrderBy(name => name, StringComparer.Ordinal) .ToArray(); - Assert.Equal(["MxGateway.Worker"], projectsWithMxAccessReference); + Assert.Equal( + ["MxGateway.Worker", "MxGateway.Worker.Tests"], + projectsWithMxAccessReference); } private static bool ProjectReferencesMxAccess(string projectPath)