refactor(opcuaclient): remove vestigial TargetNamespaceKind + UnsMappingTable (#648)
Nothing read the mapping table beyond the startup validator; v3 UNS projection is
explicit via UnsTagReference. Legacy keys in stored DriverConfig are ignored (pinned).
Reverts the docker-dev opc-plc seed workaround from fdee129f.
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
+1
-58
@@ -6,68 +6,11 @@ using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Regression coverage for driver-specs.md §8 namespace handling — the
|
||||
/// <c>TargetNamespaceKind</c> startup enforcement and the server-stable NodeId encoding
|
||||
/// that <see cref="NamespaceMap"/> produces (findings Driver.OpcUaClient-004).
|
||||
/// Regression coverage for the server-stable NodeId encoding that <see cref="NamespaceMap"/> produces (findings Driver.OpcUaClient-004).
|
||||
/// </summary>
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class OpcUaClientNamespaceTests
|
||||
{
|
||||
// ---- Driver.OpcUaClient-004: TargetNamespaceKind startup enforcement ----
|
||||
|
||||
/// <summary>Verifies that Equipment namespace kind without mapping table is rejected.</summary>
|
||||
[Fact]
|
||||
public void ValidateNamespaceKind_Equipment_without_mapping_table_is_rejected()
|
||||
{
|
||||
// §8: an Equipment-kind instance gateways raw equipment data and MUST carry a
|
||||
// config-driven UNS mapping table — remote nodes don't conform to UNS by default.
|
||||
var opts = new OpcUaClientDriverOptions { TargetNamespaceKind = OpcUaTargetNamespaceKind.Equipment };
|
||||
Should.Throw<InvalidOperationException>(() => OpcUaClientDriver.ValidateNamespaceKind(opts))
|
||||
.Message.ShouldContain("UnsMappingTable");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Equipment namespace kind with mapping table passes.</summary>
|
||||
[Fact]
|
||||
public void ValidateNamespaceKind_Equipment_with_mapping_table_passes()
|
||||
{
|
||||
var opts = new OpcUaClientDriverOptions
|
||||
{
|
||||
TargetNamespaceKind = OpcUaTargetNamespaceKind.Equipment,
|
||||
UnsMappingTable = new Dictionary<string, string> { ["Line1"] = "Site/AreaA/Line1" },
|
||||
};
|
||||
Should.NotThrow(() => OpcUaClientDriver.ValidateNamespaceKind(opts));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that SystemPlatform namespace kind with mapping table is rejected.</summary>
|
||||
[Fact]
|
||||
public void ValidateNamespaceKind_SystemPlatform_with_mapping_table_is_rejected()
|
||||
{
|
||||
// §8: processed data preserves its own hierarchy — a UNS mapping table is ambiguous.
|
||||
var opts = new OpcUaClientDriverOptions
|
||||
{
|
||||
TargetNamespaceKind = OpcUaTargetNamespaceKind.SystemPlatform,
|
||||
UnsMappingTable = new Dictionary<string, string> { ["x"] = "y" },
|
||||
};
|
||||
Should.Throw<InvalidOperationException>(() => OpcUaClientDriver.ValidateNamespaceKind(opts))
|
||||
.Message.ShouldContain("SystemPlatform");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that SystemPlatform namespace kind without mapping table passes.</summary>
|
||||
[Fact]
|
||||
public void ValidateNamespaceKind_SystemPlatform_without_mapping_table_passes()
|
||||
{
|
||||
var opts = new OpcUaClientDriverOptions { TargetNamespaceKind = OpcUaTargetNamespaceKind.SystemPlatform };
|
||||
Should.NotThrow(() => OpcUaClientDriver.ValidateNamespaceKind(opts));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the default target namespace kind is Equipment.</summary>
|
||||
[Fact]
|
||||
public void Default_TargetNamespaceKind_is_Equipment()
|
||||
{
|
||||
// §8 comparison table: OPC UA Client default lane is Equipment.
|
||||
new OpcUaClientDriverOptions().TargetNamespaceKind.ShouldBe(OpcUaTargetNamespaceKind.Equipment);
|
||||
}
|
||||
|
||||
// ---- Driver.OpcUaClient-004: server-stable NodeId encoding ----
|
||||
|
||||
/// <summary>Verifies that NamespaceMap.FromSession rejects null session.</summary>
|
||||
|
||||
Reference in New Issue
Block a user