test: preserve server SDK 2.0 value security and history contracts

This commit is contained in:
Joseph Doherty
2026-11-10 10:37:52 -05:00
parent ac5e9d84f0
commit 9cddc9306b
45 changed files with 1215 additions and 641 deletions
@@ -1,3 +1,4 @@
using Opc.Ua;
using Microsoft.Extensions.Logging.Abstractions;
using Opc.Ua.Server;
using Shouldly;
@@ -34,7 +35,7 @@ public sealed class SdkServiceLevelPublisherTests : IDisposable
var proxy = (FaultingServer)(object)server;
proxy.Node = new Opc.Ua.ServerObjectState(null)
{
ServiceLevel = new Opc.Ua.PropertyState<byte>(null),
ServiceLevel = new Opc.Ua.PropertyState<byte>.Implementation<Opc.Ua.VariantBuilder>(null),
};
proxy.Fault = new InvalidOperationException("controlled diagnostics failure");
var publisher = new SdkServiceLevelPublisher(server, NullLogger<SdkServiceLevelPublisher>.Instance);
@@ -48,7 +49,7 @@ public sealed class SdkServiceLevelPublisherTests : IDisposable
protected override object? Invoke(System.Reflection.MethodInfo? method, object?[]? args)
{
if (method?.Name == "get_ServerObject") return Node;
if (method?.Name == "get_DiagnosticsLock") throw Fault!;
if (method?.Name == "UpdateServerDiagnostics") throw Fault!;
throw new NotSupportedException(method?.Name);
}
}
@@ -69,7 +70,7 @@ public sealed class SdkServiceLevelPublisherTests : IDisposable
PkiStoreRoot = _pkiRoot,
},
NullLogger<OpcUaApplicationHost>.Instance),
() => new StandardServer(), Ct);
() => new OtOpcUaSdkServer(), Ct);
await using var host = started.Host;
var server = started.Server;
@@ -100,7 +101,7 @@ public sealed class SdkServiceLevelPublisherTests : IDisposable
PkiStoreRoot = _pkiRoot,
},
NullLogger<OpcUaApplicationHost>.Instance),
() => new StandardServer(), Ct);
() => new OtOpcUaSdkServer(), Ct);
await using var host = started.Host;
var server = started.Server;
var publisher = new SdkServiceLevelPublisher(
@@ -111,7 +112,7 @@ public sealed class SdkServiceLevelPublisherTests : IDisposable
publisher.Publish(150);
publisher.Publish(240);
server.CurrentInstance.ServerObject.ServiceLevel.Value.ShouldBe((byte)240);
server.CurrentInstance.ServerObject.ServiceLevel!.Value.ShouldBe((byte)240);
}
/// <summary>Disposes and cleans up the test resources.</summary>