using Xunit; namespace ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.IntegrationTests; /// /// Opt-in gate for every integration test that WRITES to the endpoint under test. A write test runs only /// when AB_SERVER_ALLOW_WRITES=1, in addition to its own reachability / profile conditions, so /// pointing an endpoint variable at a real controller (a production press in Task 21) can never write to /// it by accident. It also refuses while AB_DIFF_ENDPOINT is set, because that variable means a /// read-only differential run is in progress. The ab_server / simulator runs set the opt-in explicitly. /// public static class IntegrationWriteGate { public const string AllowWritesVar = "AB_SERVER_ALLOW_WRITES"; public const string DifferentialEndpointVar = "AB_DIFF_ENDPOINT"; /// Skips the calling test unless writes are explicitly allowed for this run. public static void SkipUnlessWritesAllowed() { if (Environment.GetEnvironmentVariable(DifferentialEndpointVar) is { Length: > 0 }) Assert.Skip($"Write test refused: {DifferentialEndpointVar} is set, so a read-only differential run is in progress."); if (Environment.GetEnvironmentVariable(AllowWritesVar) != "1") Assert.Skip($"Write test: set {AllowWritesVar}=1 to allow writes to the endpoint under test " + "(simulator runs only — never a production controller)."); } }