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>
73 lines
3.3 KiB
C#
73 lines
3.3 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Server.Tests.Alarms;
|
|
|
|
/// <summary>
|
|
/// PR B.3 — pins the routing decision DriverNodeManager makes when registering
|
|
/// an AlarmConditionState: drivers that implement <see cref="IAlarmSource"/>
|
|
/// get an acknowledger that calls AcknowledgeAsync (driver-native path); drivers
|
|
/// that don't fall back to the IWritable sub-attribute write.
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public sealed class DriverAlarmSourceAcknowledgerRoutingTests
|
|
{
|
|
[Fact]
|
|
public void Driver_with_IAlarmSource_is_recognized()
|
|
{
|
|
IDriver driver = new FakeDriverWithAlarmSource("drv-1");
|
|
(driver is IAlarmSource).ShouldBeTrue(
|
|
"fakes that participate in the routing-test fixture must report IAlarmSource");
|
|
}
|
|
|
|
[Fact]
|
|
public void Driver_without_IAlarmSource_falls_to_writable_path()
|
|
{
|
|
IDriver driver = new FakeDriverNoAlarmSource("drv-2");
|
|
(driver is IAlarmSource).ShouldBeFalse(
|
|
"drivers without IAlarmSource take the legacy DriverWritableAcknowledger path");
|
|
}
|
|
|
|
private sealed class FakeDriverWithAlarmSource(string id) : IDriver, IAlarmSource
|
|
{
|
|
public string DriverInstanceId { get; } = id;
|
|
public string DriverType => "FakeAlarmSource";
|
|
public Task InitializeAsync(string c, CancellationToken ct) => Task.CompletedTask;
|
|
public Task ReinitializeAsync(string c, CancellationToken ct) => Task.CompletedTask;
|
|
public Task ShutdownAsync(CancellationToken ct) => Task.CompletedTask;
|
|
public DriverHealth GetHealth() => new(DriverState.Healthy, DateTime.UtcNow, null);
|
|
public long GetMemoryFootprint() => 0;
|
|
public Task FlushOptionalCachesAsync(CancellationToken ct) => Task.CompletedTask;
|
|
|
|
public Task<IAlarmSubscriptionHandle> SubscribeAlarmsAsync(
|
|
IReadOnlyList<string> sourceNodeIds, CancellationToken cancellationToken)
|
|
=> Task.FromResult<IAlarmSubscriptionHandle>(new FakeHandle("h"));
|
|
public Task UnsubscribeAlarmsAsync(IAlarmSubscriptionHandle handle, CancellationToken cancellationToken)
|
|
=> Task.CompletedTask;
|
|
public Task AcknowledgeAsync(
|
|
IReadOnlyList<AlarmAcknowledgeRequest> acknowledgements, CancellationToken cancellationToken)
|
|
=> Task.CompletedTask;
|
|
|
|
public event EventHandler<AlarmEventArgs>? OnAlarmEvent;
|
|
private void NoUnusedWarning() => OnAlarmEvent?.Invoke(this, null!);
|
|
}
|
|
|
|
private sealed class FakeDriverNoAlarmSource(string id) : IDriver
|
|
{
|
|
public string DriverInstanceId { get; } = id;
|
|
public string DriverType => "FakeNoAlarmSource";
|
|
public Task InitializeAsync(string c, CancellationToken ct) => Task.CompletedTask;
|
|
public Task ReinitializeAsync(string c, CancellationToken ct) => Task.CompletedTask;
|
|
public Task ShutdownAsync(CancellationToken ct) => Task.CompletedTask;
|
|
public DriverHealth GetHealth() => new(DriverState.Healthy, DateTime.UtcNow, null);
|
|
public long GetMemoryFootprint() => 0;
|
|
public Task FlushOptionalCachesAsync(CancellationToken ct) => Task.CompletedTask;
|
|
}
|
|
|
|
private sealed class FakeHandle(string id) : IAlarmSubscriptionHandle
|
|
{
|
|
public string DiagnosticId { get; } = id;
|
|
}
|
|
}
|