test: verify SDK 2 driver boundaries and lifecycle contracts
This commit is contained in:
@@ -74,6 +74,35 @@ public sealed class OpcUaClientNamespaceTests
|
||||
NamespaceMap.TryResolve(null!, "ns=1;s=X", out _).ShouldBeFalse();
|
||||
}
|
||||
|
||||
public static TheoryData<NodeId> IdentifierKinds =>
|
||||
[
|
||||
new NodeId(123u, 1),
|
||||
new NodeId("literal;i=123", 1),
|
||||
new NodeId(Guid.Parse("db8d57c4-316f-4517-819f-194c3a6db955"), 1),
|
||||
new NodeId(new byte[] { 0, 1, 127, 255 }.ToByteString(), 1),
|
||||
];
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(IdentifierKinds))]
|
||||
public void Stable_reference_rebinds_namespace_without_changing_identifier_type(NodeId original)
|
||||
{
|
||||
var stable = TestMap("http://opcfoundation.org/UA/", "urn:remote:server").ToStableReference(original);
|
||||
var context = ServiceMessageContext.Create(SdkTelemetry.Context);
|
||||
context.NamespaceUris.Append("urn:other");
|
||||
context.NamespaceUris.Append("urn:remote:server");
|
||||
var session = new Moq.Mock<Opc.Ua.Client.ISession>();
|
||||
session.SetupGet(s => s.MessageContext).Returns(context);
|
||||
NamespaceMap.TryResolve(session.Object, stable, out var rebound).ShouldBeTrue();
|
||||
rebound.NamespaceIndex.ShouldBe((ushort)2);
|
||||
rebound.IdType.ShouldBe(original.IdType);
|
||||
rebound.IdentifierAsString.ShouldBe(original.IdentifierAsString);
|
||||
if (original.IdType == IdType.Opaque)
|
||||
{
|
||||
rebound.TryGetValue(out ByteString identifier).ShouldBeTrue();
|
||||
identifier.ToArray().ShouldBe(new byte[] { 0, 1, 127, 255 });
|
||||
}
|
||||
}
|
||||
|
||||
// ---- v3: RawPath → upstream node id resolution table ----
|
||||
|
||||
/// <summary>Verifies a RawPath resolves to the upstream node id authored in its TagConfig.nodeId.</summary>
|
||||
|
||||
Reference in New Issue
Block a user