27 lines
1.4 KiB
C#
27 lines
1.4 KiB
C#
using Xunit;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.AbCip.IntegrationTests;
|
|
|
|
/// <summary>
|
|
/// Opt-in gate for every integration test that WRITES to the endpoint under test. A write test runs only
|
|
/// when <c>AB_SERVER_ALLOW_WRITES=1</c>, 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 <c>AB_DIFF_ENDPOINT</c> is set, because that variable means a
|
|
/// read-only differential run is in progress. The ab_server / simulator runs set the opt-in explicitly.
|
|
/// </summary>
|
|
public static class IntegrationWriteGate
|
|
{
|
|
public const string AllowWritesVar = "AB_SERVER_ALLOW_WRITES";
|
|
public const string DifferentialEndpointVar = "AB_DIFF_ENDPOINT";
|
|
|
|
/// <summary>Skips the calling test unless writes are explicitly allowed for this run.</summary>
|
|
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).");
|
|
}
|
|
}
|