test(drivers): failing repro for CONV-4 equipment-tag ResolveHost mis-keying
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.AbCip;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.AbCip.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// CONV-4 — <see cref="AbCipDriver.ResolveHost"/> keys per-host resilience (bulkhead / circuit
|
||||
/// breaker). It must resolve an equipment-tag reference (raw TagConfig JSON) to its OWN device
|
||||
/// host, not fall back to the first device — otherwise a broken device B trips device A's
|
||||
/// breaker. Authored tags and unknown refs keep the current fallback.
|
||||
/// </summary>
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class AbCipResolveHostTests
|
||||
{
|
||||
private const string DeviceA = "ab://10.0.0.5/1,0";
|
||||
private const string DeviceB = "ab://10.0.0.6/1,0";
|
||||
|
||||
private static AbCipDriver NewDriver() => new(
|
||||
new AbCipDriverOptions
|
||||
{
|
||||
Devices = [new AbCipDeviceOptions(DeviceA), new AbCipDeviceOptions(DeviceB)],
|
||||
Probe = new AbCipProbeOptions { Enabled = false },
|
||||
},
|
||||
"abcip-1", new FakeAbCipTagFactory());
|
||||
|
||||
/// <summary>An equipment-tag ref naming device B resolves to device B's host, not the first device.</summary>
|
||||
[Fact]
|
||||
public void ResolveHost_EquipmentTagRef_ReturnsItsOwnDeviceHost()
|
||||
{
|
||||
var drv = NewDriver();
|
||||
var json = $$"""{"deviceHostAddress":"{{DeviceB}}","tagPath":"Motor1.Speed","dataType":"DInt"}""";
|
||||
drv.ResolveHost(json).ShouldBe(DeviceB);
|
||||
}
|
||||
|
||||
/// <summary>An unresolvable ref keeps the current first-device fallback.</summary>
|
||||
[Fact]
|
||||
public void ResolveHost_UnknownRef_KeepsCurrentFallback()
|
||||
{
|
||||
var drv = NewDriver();
|
||||
drv.ResolveHost("totally-unknown").ShouldBe(DeviceA);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user