test: verify SDK 2 driver boundaries and lifecycle contracts

This commit is contained in:
Joseph Doherty
2026-11-10 10:21:53 -05:00
parent c6ce30121c
commit 47b66caa8d
18 changed files with 411 additions and 124 deletions
@@ -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>