feat(controlplane): EquipmentTagConfigInspector — DriverType-dispatched deploy-time TagConfig inspection (R2-11)
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.ControlPlane.AdminOperations;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.ControlPlane.Tests;
|
||||
|
||||
/// <summary>R2-11 (05/CONV-2): the DriverType-dispatched deploy-time TagConfig inspector — known drivers
|
||||
/// route to their parser's Inspect; unmapped drivers (Galaxy/OpcUaClient) skip; keys are case-insensitive.</summary>
|
||||
public sealed class EquipmentTagConfigInspectorTests
|
||||
{
|
||||
[Fact]
|
||||
public void Modbus_typo_dispatches_to_one_warning()
|
||||
{
|
||||
var warnings = EquipmentTagConfigInspector.Inspect(
|
||||
"Modbus", "{\"region\":\"HoldingRegisters\",\"address\":1,\"dataType\":\"Intt16\"}");
|
||||
warnings.ShouldHaveSingleItem();
|
||||
warnings[0].ShouldContain("Intt16");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Clean_modbus_config_has_no_warnings()
|
||||
{
|
||||
EquipmentTagConfigInspector.Inspect(
|
||||
"Modbus", "{\"region\":\"HoldingRegisters\",\"address\":1,\"dataType\":\"Int16\"}")
|
||||
.ShouldBeEmpty();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("GalaxyMxGateway")]
|
||||
[InlineData("OpcUaClient")]
|
||||
[InlineData("Unknown")]
|
||||
public void Unmapped_driver_types_are_skipped(string driverType)
|
||||
{
|
||||
EquipmentTagConfigInspector.Inspect(driverType, "{\"dataType\":\"whatever\"}").ShouldBeEmpty();
|
||||
EquipmentTagConfigInspector.IsMapped(driverType).ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("modbus")]
|
||||
[InlineData("FOCAS")]
|
||||
[InlineData("focas")]
|
||||
[InlineData("twincat")]
|
||||
public void Driver_type_matching_is_case_insensitive(string driverType)
|
||||
{
|
||||
EquipmentTagConfigInspector.IsMapped(driverType).ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Focas_writable_true_dispatches_read_only_warning()
|
||||
{
|
||||
var warnings = EquipmentTagConfigInspector.Inspect(
|
||||
"Focas", "{\"address\":\"D0100\",\"dataType\":\"Int32\",\"writable\":true}");
|
||||
warnings.ShouldContain(w => w.Contains("read-only"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Null_inputs_are_safe()
|
||||
{
|
||||
EquipmentTagConfigInspector.Inspect(null, "{}").ShouldBeEmpty();
|
||||
EquipmentTagConfigInspector.Inspect("Modbus", null).ShouldBeEmpty();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user