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>
84 lines
2.9 KiB
C#
84 lines
2.9 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
using ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Health;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Tests.Health;
|
|
|
|
/// <summary>
|
|
/// Tests for <see cref="HostConnectivityForwarder"/>'s push path. The forwarder is a
|
|
/// thin shim over <see cref="HostStatusAggregator"/>; the only invariants worth pinning
|
|
/// are that SetTransport routes correctly under the configured client name and that
|
|
/// repeated identical pushes don't produce duplicate change events (the aggregator's
|
|
/// dedup carries that — this test asserts the forwarder doesn't re-introduce them).
|
|
/// </summary>
|
|
public sealed class HostConnectivityForwarderTests
|
|
{
|
|
[Fact]
|
|
public void SetTransport_Running_PushesUnderClientName()
|
|
{
|
|
var agg = new HostStatusAggregator();
|
|
var captured = new List<HostStatusChangedEventArgs>();
|
|
agg.OnHostStatusChanged += (_, e) => captured.Add(e);
|
|
|
|
var fwd = new HostConnectivityForwarder("OtOpcUa-A", agg);
|
|
fwd.SetTransport(HostState.Running);
|
|
|
|
captured.Count.ShouldBe(1);
|
|
captured[0].HostName.ShouldBe("OtOpcUa-A");
|
|
captured[0].NewState.ShouldBe(HostState.Running);
|
|
agg.Snapshot()[0].HostName.ShouldBe("OtOpcUa-A");
|
|
}
|
|
|
|
[Fact]
|
|
public void SetTransport_StateTransition_FiresChange()
|
|
{
|
|
var agg = new HostStatusAggregator();
|
|
var fwd = new HostConnectivityForwarder("OtOpcUa-A", agg);
|
|
|
|
fwd.SetTransport(HostState.Running);
|
|
var captured = new List<HostStatusChangedEventArgs>();
|
|
agg.OnHostStatusChanged += (_, e) => captured.Add(e);
|
|
|
|
fwd.SetTransport(HostState.Stopped);
|
|
|
|
captured.Count.ShouldBe(1);
|
|
captured[0].OldState.ShouldBe(HostState.Running);
|
|
captured[0].NewState.ShouldBe(HostState.Stopped);
|
|
}
|
|
|
|
[Fact]
|
|
public void SetTransport_RepeatedSameState_DoesNotFire()
|
|
{
|
|
var agg = new HostStatusAggregator();
|
|
var fwd = new HostConnectivityForwarder("OtOpcUa-A", agg);
|
|
|
|
fwd.SetTransport(HostState.Running);
|
|
var captured = new List<HostStatusChangedEventArgs>();
|
|
agg.OnHostStatusChanged += (_, e) => captured.Add(e);
|
|
|
|
fwd.SetTransport(HostState.Running);
|
|
fwd.SetTransport(HostState.Running);
|
|
fwd.SetTransport(HostState.Running);
|
|
|
|
captured.ShouldBeEmpty();
|
|
}
|
|
|
|
[Fact]
|
|
public void Constructor_RejectsEmptyClientName()
|
|
{
|
|
var agg = new HostStatusAggregator();
|
|
Should.Throw<ArgumentException>(() => new HostConnectivityForwarder("", agg));
|
|
Should.Throw<ArgumentException>(() => new HostConnectivityForwarder(" ", agg));
|
|
}
|
|
|
|
[Fact]
|
|
public void SetTransport_AfterDispose_Throws()
|
|
{
|
|
var agg = new HostStatusAggregator();
|
|
var fwd = new HostConnectivityForwarder("OtOpcUa-A", agg);
|
|
fwd.Dispose();
|
|
Should.Throw<ObjectDisposedException>(() => fwd.SetTransport(HostState.Running));
|
|
}
|
|
}
|