Merge b626-ablegacy-focas (batch #626+)

Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
Joseph Doherty
2026-10-08 14:43:44 -04:00
17 changed files with 946 additions and 176 deletions
@@ -0,0 +1,55 @@
using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.AdminUI.Uns.TagEditors;
using ZB.MOM.WW.OtOpcUa.ControlPlane.AdminOperations;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Uns;
/// <summary>#244/#245/#247: one address authority (AbLegacyAddress.Validate) behind the editor and the deploy gate.</summary>
public sealed class AbLegacyFamilyAddressGateTests
{
private static string Cfg(string address) => "{\"address\":\"" + address + "\",\"dataType\":\"Int\"}";
[Theory]
[InlineData("{\"PlcFamily\":\"Plc5\"}", "I:018", true)] // octal 8 on PLC-5
[InlineData("{\"PlcFamily\":\"Plc5\"}", "I:017/07", false)]
[InlineData("{\"PlcFamily\":\"Slc500\"}", "I:018", false)] // control: decimal on SLC
[InlineData("{\"plcFamily\":\"plc5\"}", "I:018", true)] // key + value case-insensitive
[InlineData("{\"PlcFamily\":\"Slc500\"}", "RTC:0.HR", true)] // function file off MicroLogix
[InlineData("{\"PlcFamily\":\"MicroLogix\"}", "RTC:0.HR", false)]
[InlineData(null, "RTC:0.HR", true)] // absent family = runtime default SLC 500
[InlineData("{\"PlcFamily\":\"Bogus\"}", "I:018", false)] // unknown family: never stricter than the runtime
[InlineData("{\"PlcFamily\":\"Slc500\"}", "Q9:0", true)]
public void Gate_checks_the_address_against_the_device_family(string? deviceConfig, string address, bool warns)
{
var w = EquipmentTagConfigInspector.Inspect(DriverTypeNames.AbLegacy, Cfg(address), deviceConfig);
(w.Count > 0).ShouldBe(warns, string.Join("; ", w));
}
[Fact]
public void Gate_warns_about_indirect_addresses_which_never_read()
{
EquipmentTagConfigInspector.Inspect(DriverTypeNames.AbLegacy, Cfg("N7:[N7:0]"), "{\"PlcFamily\":\"Slc500\"}")
.ShouldContain(x => x.Contains("indirect"));
}
[Theory]
[InlineData("N7:0", null)]
[InlineData("I:018", null)] // family unknown to the editor: another family accepts it
[InlineData("RTC:0.HR", null)] // MicroLogix accepts it
[InlineData("Q9:0", "any PLC family")]
public void Editor_validates_only_the_family_independent_shape(string address, string? error)
{
var result = AbLegacyTagConfigModel.FromJson(Cfg(address)).Validate();
if (error is null) result.ShouldBeNull(); else result!.ShouldContain(error);
}
[Fact]
public void Editor_is_never_stricter_than_the_gate()
{
const string address = "Q9:0";
AbLegacyTagConfigModel.FromJson(Cfg(address)).Validate().ShouldNotBeNull();
EquipmentTagConfigInspector.Inspect(DriverTypeNames.AbLegacy, Cfg(address), null).ShouldNotBeEmpty();
}
}
@@ -346,7 +346,7 @@ public sealed class RawTagConfigGateTests
public void A_browse_committed_config_passes_the_gate(string driverType)
{
var tagConfig = RawBrowseCommitMapper.BuildTagConfig(
driverType, "SomeAddress", BrowseFieldsFor(driverType));
driverType, driverType == DriverTypeNames.AbLegacy ? "N7:0" : "SomeAddress", BrowseFieldsFor(driverType));
TagConfigValidator.Validate(driverType, tagConfig).ShouldBeNull(
$"browse-commit for {driverType} must not author a config the import refuses");