fix(test): align DualEndpointTests SDK to 1.5.374.126 + sync API
This commit is contained in:
@@ -3,7 +3,6 @@ using System.Net.Sockets;
|
|||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
using Opc.Ua;
|
using Opc.Ua;
|
||||||
using Opc.Ua.Client;
|
using Opc.Ua.Client;
|
||||||
using Opc.Ua.Configuration;
|
|
||||||
using Opc.Ua.Server;
|
using Opc.Ua.Server;
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
@@ -70,6 +69,9 @@ public sealed class DualEndpointTests
|
|||||||
|
|
||||||
private static async Task<string[]> ReadServerArrayAsync(string endpointUrl)
|
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
|
var appConfig = new ApplicationConfiguration
|
||||||
{
|
{
|
||||||
ApplicationName = "OtOpcUa.DualEndpointClient",
|
ApplicationName = "OtOpcUa.DualEndpointClient",
|
||||||
@@ -82,31 +84,23 @@ public sealed class DualEndpointTests
|
|||||||
},
|
},
|
||||||
ClientConfiguration = new ClientConfiguration { DefaultSessionTimeout = 60_000 },
|
ClientConfiguration = new ClientConfiguration { DefaultSessionTimeout = 60_000 },
|
||||||
};
|
};
|
||||||
// SDK 1.5.378 deprecates the no-arg ctors of CertificateValidator / DefaultSessionFactory
|
await appConfig.Validate(ApplicationType.Client);
|
||||||
// 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);
|
|
||||||
appConfig.CertificateValidator.CertificateValidation += (_, e) => e.Accept = true;
|
appConfig.CertificateValidator.CertificateValidation += (_, e) => e.Accept = true;
|
||||||
|
|
||||||
var endpoint = await CoreClientUtils.SelectEndpointAsync(
|
var endpoint = CoreClientUtils.SelectEndpoint(appConfig, endpointUrl, useSecurity: false);
|
||||||
appConfig, endpointUrl, useSecurity: false, discoverTimeout: 15_000, telemetry,
|
|
||||||
CancellationToken.None);
|
|
||||||
var endpointConfiguration = EndpointConfiguration.Create(appConfig);
|
var endpointConfiguration = EndpointConfiguration.Create(appConfig);
|
||||||
var configuredEndpoint = new ConfiguredEndpoint(null, endpoint, endpointConfiguration);
|
var configuredEndpoint = new ConfiguredEndpoint(null, endpoint, endpointConfiguration);
|
||||||
|
|
||||||
var factory = new DefaultSessionFactory(telemetry);
|
using var session = await ClientSession.Create(
|
||||||
using var session = (ClientSession)await factory.CreateAsync(
|
|
||||||
appConfig,
|
appConfig,
|
||||||
configuredEndpoint,
|
configuredEndpoint,
|
||||||
updateBeforeConnect: false,
|
updateBeforeConnect: false,
|
||||||
sessionName: "DualEndpointTests",
|
sessionName: "DualEndpointTests",
|
||||||
sessionTimeout: 60_000,
|
sessionTimeout: 60_000,
|
||||||
identity: new UserIdentity(new AnonymousIdentityToken()),
|
identity: new UserIdentity(new AnonymousIdentityToken()),
|
||||||
preferredLocales: null,
|
preferredLocales: null);
|
||||||
CancellationToken.None);
|
|
||||||
|
|
||||||
var value = await session.ReadValueAsync(VariableIds.Server_ServerArray, CancellationToken.None);
|
var value = session.ReadValue(VariableIds.Server_ServerArray);
|
||||||
return (string[])value.Value;
|
return (string[])value.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,12 @@
|
|||||||
<PackageReference Include="xunit.v3"/>
|
<PackageReference Include="xunit.v3"/>
|
||||||
<PackageReference Include="Shouldly"/>
|
<PackageReference Include="Shouldly"/>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
|
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
|
||||||
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client"/>
|
<!-- Pin to 1.5.374.126 to match the server src (OpcUaServer.csproj). Mixing transitive
|
||||||
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration"/>
|
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="Microsoft.Extensions.Logging.Abstractions"/>
|
||||||
<PackageReference Include="xunit.runner.visualstudio">
|
<PackageReference Include="xunit.runner.visualstudio">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
|||||||
Reference in New Issue
Block a user