fix(test): align DualEndpointTests SDK to 1.5.374.126 + sync API

This commit is contained in:
Joseph Doherty
2026-05-26 11:34:01 -04:00
parent dce2528c68
commit a5412c16a3
2 changed files with 14 additions and 16 deletions

View File

@@ -3,7 +3,6 @@ using System.Net.Sockets;
using Microsoft.Extensions.Logging.Abstractions;
using Opc.Ua;
using Opc.Ua.Client;
using Opc.Ua.Configuration;
using Opc.Ua.Server;
using Shouldly;
using Xunit;
@@ -70,6 +69,9 @@ public sealed class DualEndpointTests
private static async Task<string[]> ReadServerArrayAsync(string endpointUrl)
{
// SDK 1.5.374 sync-style session-open path — mirrors src/Client/.../DefaultSessionFactory.cs
// and DefaultApplicationConfigurationFactory.cs. The 1.5.378 telemetry/async overloads are
// not available at this pinned version.
var appConfig = new ApplicationConfiguration
{
ApplicationName = "OtOpcUa.DualEndpointClient",
@@ -82,31 +84,23 @@ public sealed class DualEndpointTests
},
ClientConfiguration = new ClientConfiguration { DefaultSessionTimeout = 60_000 },
};
// SDK 1.5.378 deprecates the no-arg ctors of CertificateValidator / DefaultSessionFactory
// and the non-telemetry overloads of SelectEndpointAsync. Inject a no-op telemetry context
// so the integration test (with TreatWarningsAsErrors=true) doesn't trip the CS0618 wall.
var telemetry = DefaultTelemetry.Create(static _ => { });
await appConfig.ValidateAsync(ApplicationType.Client, CancellationToken.None);
await appConfig.Validate(ApplicationType.Client);
appConfig.CertificateValidator.CertificateValidation += (_, e) => e.Accept = true;
var endpoint = await CoreClientUtils.SelectEndpointAsync(
appConfig, endpointUrl, useSecurity: false, discoverTimeout: 15_000, telemetry,
CancellationToken.None);
var endpoint = CoreClientUtils.SelectEndpoint(appConfig, endpointUrl, useSecurity: false);
var endpointConfiguration = EndpointConfiguration.Create(appConfig);
var configuredEndpoint = new ConfiguredEndpoint(null, endpoint, endpointConfiguration);
var factory = new DefaultSessionFactory(telemetry);
using var session = (ClientSession)await factory.CreateAsync(
using var session = await ClientSession.Create(
appConfig,
configuredEndpoint,
updateBeforeConnect: false,
sessionName: "DualEndpointTests",
sessionTimeout: 60_000,
identity: new UserIdentity(new AnonymousIdentityToken()),
preferredLocales: null,
CancellationToken.None);
preferredLocales: null);
var value = await session.ReadValueAsync(VariableIds.Server_ServerArray, CancellationToken.None);
var value = session.ReadValue(VariableIds.Server_ServerArray);
return (string[])value.Value;
}

View File

@@ -11,8 +11,12 @@
<PackageReference Include="xunit.v3"/>
<PackageReference Include="Shouldly"/>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client"/>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration"/>
<!-- Pin to 1.5.374.126 to match the server src (OpcUaServer.csproj). Mixing transitive
Opc.Ua.Core across 1.5.374 / 1.5.378 produces a MissingMethodException at runtime
because ApplicationInstance.Start(ServerBase) (sync) was removed in 1.5.378 in
favour of StartAsync. Stays here until Opc.Ua.Server publishes 1.5.378.x. -->
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client" VersionOverride="1.5.374.126"/>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration" VersionOverride="1.5.374.126"/>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions"/>
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>