Group all 69 projects into category subfolders under src/ and tests/ so the Rider Solution Explorer mirrors the module structure. Folders: Core, Server, Drivers (with a nested Driver CLIs subfolder), Client, Tooling. - Move every project folder on disk with git mv (history preserved as renames). - Recompute relative paths in 57 .csproj files: cross-category ProjectReferences, the lib/ HintPath+None refs in Driver.Historian.Wonderware, and the external mxaccessgw refs in Driver.Galaxy and its test project. - Rebuild ZB.MOM.WW.OtOpcUa.slnx with nested solution folders. - Re-prefix project paths in functional scripts (e2e, compliance, smoke SQL, integration, install). Build green (0 errors); unit tests pass. Docs left for a separate pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
83 lines
2.8 KiB
C#
83 lines
2.8 KiB
C#
using System;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Driver.Historian.Wonderware;
|
|
using ZB.MOM.WW.OtOpcUa.Driver.Historian.Wonderware.Backend;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Host.Tests
|
|
{
|
|
/// <summary>
|
|
/// PR C.2 — pins the env-var contract that gates whether the sidecar boots an
|
|
/// alarm-event writer. Default-on (when the historian itself is enabled) so a
|
|
/// fresh deploy picks up the writer without a service-config edit; explicit
|
|
/// <c>false</c> opts a read-only deployment out.
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public sealed class ProgramAlarmWriterTests
|
|
{
|
|
[Fact]
|
|
public void BuildAlarmWriter_returns_writer_when_env_unset()
|
|
{
|
|
using var _ = ScopedEnv("OTOPCUA_HISTORIAN_ALARM_WRITE_ENABLED", null);
|
|
|
|
var writer = Program.BuildAlarmWriter();
|
|
|
|
writer.ShouldNotBeNull();
|
|
writer.ShouldBeOfType<AahClientManagedAlarmEventWriter>();
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("true")]
|
|
[InlineData("True")]
|
|
[InlineData("TRUE")]
|
|
public void BuildAlarmWriter_returns_writer_when_env_explicitly_true(string value)
|
|
{
|
|
using var _ = ScopedEnv("OTOPCUA_HISTORIAN_ALARM_WRITE_ENABLED", value);
|
|
|
|
var writer = Program.BuildAlarmWriter();
|
|
|
|
writer.ShouldNotBeNull();
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("false")]
|
|
[InlineData("False")]
|
|
[InlineData("FALSE")]
|
|
public void BuildAlarmWriter_returns_null_when_env_false(string value)
|
|
{
|
|
using var _ = ScopedEnv("OTOPCUA_HISTORIAN_ALARM_WRITE_ENABLED", value);
|
|
|
|
var writer = Program.BuildAlarmWriter();
|
|
|
|
writer.ShouldBeNull();
|
|
}
|
|
|
|
[Fact]
|
|
public void BuildAlarmWriter_treats_unrecognized_value_as_enabled()
|
|
{
|
|
// Anything other than the literal "false" (case-insensitive) keeps the writer
|
|
// wired — fail-open under accidental misconfiguration so an alarm-write deploy
|
|
// doesn't silently lose alarms because of a typo.
|
|
using var _ = ScopedEnv("OTOPCUA_HISTORIAN_ALARM_WRITE_ENABLED", "yes");
|
|
|
|
var writer = Program.BuildAlarmWriter();
|
|
|
|
writer.ShouldNotBeNull();
|
|
}
|
|
|
|
private static IDisposable ScopedEnv(string name, string? value)
|
|
{
|
|
var prior = Environment.GetEnvironmentVariable(name);
|
|
Environment.SetEnvironmentVariable(name, value);
|
|
return new DisposableAction(() => Environment.SetEnvironmentVariable(name, prior));
|
|
}
|
|
|
|
private sealed class DisposableAction : IDisposable
|
|
{
|
|
private readonly Action _action;
|
|
public DisposableAction(Action action) { _action = action; }
|
|
public void Dispose() => _action();
|
|
}
|
|
}
|
|
}
|