namespace ZB.MOM.WW.MxGateway.Tests.ProjectStructure; /// Pins the structure of the windev worker CI script. public sealed class WindevCiContractTests { /// Verifies live mode runs the Windows test tiers in the documented order. [Fact] public void LiveMode_RunsWindowsTiersInDocumentedOrder() { DirectoryInfo repositoryRoot = FindRepositoryRoot(); string script = File.ReadAllText( Path.Combine(repositoryRoot.FullName, "scripts", "ci", "windev-worker-ci.ps1")); string[] orderedSteps = [ "Invoke-Native 'x86 Worker build'", "Invoke-Native 'x86 Worker.Tests'", "Invoke-Native 'full slnx build'", "Invoke-Native 'gateway tests on Windows'", "Invoke-Native 'live-MXAccess smoke'", ]; int previousIndex = -1; foreach (string step in orderedSteps) { int currentIndex = script.IndexOf(step, StringComparison.Ordinal); Assert.True(currentIndex >= 0, $"Missing windev live-mode step: {step}"); Assert.True(currentIndex > previousIndex, $"Windev live-mode step is out of order: {step}"); previousIndex = currentIndex; } Assert.Contains( "dotnet test $gatewayTests -c Release --no-build", script, StringComparison.Ordinal); } private static DirectoryInfo FindRepositoryRoot() { DirectoryInfo? current = new(AppContext.BaseDirectory); while (current is not null) { if (File.Exists(Path.Combine(current.FullName, "CLAUDE.md")) && Directory.Exists(Path.Combine(current.FullName, "src")) && Directory.Exists(Path.Combine(current.FullName, "scripts"))) { return current; } current = current.Parent; } throw new InvalidOperationException("Could not locate the repository root from the test output directory."); } }