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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.AbLegacy;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// CONV-4 — <see cref="AbLegacyDriver.ResolveHost"/> must resolve an equipment-tag reference
|
||||
/// (raw TagConfig JSON) to its OWN device host so per-host breaker keys are correct for
|
||||
/// equipment tags, not the first-device fallback.
|
||||
/// </summary>
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class AbLegacyResolveHostTests
|
||||
{
|
||||
private const string DeviceA = "ab://10.0.0.5/1,0";
|
||||
private const string DeviceB = "ab://10.0.0.6/1,0";
|
||||
|
||||
private static AbLegacyDriver NewDriver() => new(
|
||||
new AbLegacyDriverOptions
|
||||
{
|
||||
Devices = [new AbLegacyDeviceOptions(DeviceA), new AbLegacyDeviceOptions(DeviceB)],
|
||||
Probe = new AbLegacyProbeOptions { Enabled = false },
|
||||
},
|
||||
"ablegacy-1", new FakeAbLegacyTagFactory());
|
||||
|
||||
/// <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}}","address":"N7:0","dataType":"Int"}""";
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.FOCAS;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// CONV-4 — <see cref="FocasDriver.ResolveHost"/> must resolve an equipment-tag reference (raw
|
||||
/// TagConfig JSON) to its OWN device host so per-host breaker keys are correct for equipment
|
||||
/// tags. An address-less equipment ref (FOCAS coalesces a missing <c>deviceHostAddress</c> to
|
||||
/// <c>""</c>) must fall back rather than key an empty host.
|
||||
/// </summary>
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class FocasResolveHostTests
|
||||
{
|
||||
private const string DeviceA = "focas://10.0.0.5:8193";
|
||||
private const string DeviceB = "focas://10.0.0.6:8193";
|
||||
|
||||
private static FocasDriver NewDriver() => new(
|
||||
new FocasDriverOptions
|
||||
{
|
||||
Devices = [new FocasDeviceOptions(DeviceA), new FocasDeviceOptions(DeviceB)],
|
||||
Probe = new FocasProbeOptions { Enabled = false },
|
||||
},
|
||||
"focas-1", new FakeFocasClientFactory());
|
||||
|
||||
/// <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}}","address":"R100","dataType":"Byte"}""";
|
||||
drv.ResolveHost(json).ShouldBe(DeviceB);
|
||||
}
|
||||
|
||||
/// <summary>An equipment ref with no deviceHostAddress falls back to the first device, not an empty host.</summary>
|
||||
[Fact]
|
||||
public void ResolveHost_EquipmentTagRef_WithoutDeviceHost_FallsBack()
|
||||
{
|
||||
var drv = NewDriver();
|
||||
var json = """{"address":"R100","dataType":"Byte"}""";
|
||||
drv.ResolveHost(json).ShouldBe(DeviceA);
|
||||
}
|
||||
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.TwinCAT;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// CONV-4 — <see cref="TwinCATDriver.ResolveHost"/> must resolve an equipment-tag reference
|
||||
/// (raw TagConfig JSON) to its OWN device host so per-host breaker keys are correct for
|
||||
/// equipment tags, not the first-device fallback.
|
||||
/// </summary>
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class TwinCATResolveHostTests
|
||||
{
|
||||
private const string DeviceA = "ads://5.23.91.23.1.1:851";
|
||||
private const string DeviceB = "ads://5.23.91.23.1.2:851";
|
||||
|
||||
private static TwinCATDriver NewDriver() => new(
|
||||
new TwinCATDriverOptions
|
||||
{
|
||||
Devices = [new TwinCATDeviceOptions(DeviceA), new TwinCATDeviceOptions(DeviceB)],
|
||||
Probe = new TwinCATProbeOptions { Enabled = false },
|
||||
EnableControllerBrowse = false,
|
||||
},
|
||||
"twincat-1", new FakeTwinCATClientFactory());
|
||||
|
||||
/// <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}}","symbolPath":"MAIN.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