bd6c0b4d3d
Add missing <returns>/<param>/<summary>/<typeparam> tags and clean up misused inheritdoc across 481 files so the documented API surface is complete. Documentation-only (zero code lines changed). The 131 remaining findings are inheritdoc-style warnings deliberately left to preserve hand-written implementation rationale (plan-decision notes, race-condition explanations).
75 lines
3.3 KiB
C#
75 lines
3.3 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Tests;
|
|
|
|
/// <summary>
|
|
/// Scaffold tests for <see cref="OpcUaClientDriver"/>'s <see cref="ITagDiscovery"/>
|
|
/// surface that don't require a live remote server. Live-browse coverage lands in a
|
|
/// follow-up PR once the in-process OPC UA server fixture is scaffolded.
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public sealed class OpcUaClientDiscoveryTests
|
|
{
|
|
/// <summary>Verifies that DiscoverAsync throws InvalidOperationException when not initialized.</summary>
|
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
|
[Fact]
|
|
public async Task DiscoverAsync_without_initialize_throws_InvalidOperationException()
|
|
{
|
|
using var drv = new OpcUaClientDriver(new OpcUaClientDriverOptions(), "opcua-disco");
|
|
var builder = new NullAddressSpaceBuilder();
|
|
await Should.ThrowAsync<InvalidOperationException>(async () =>
|
|
await drv.DiscoverAsync(builder, TestContext.Current.CancellationToken));
|
|
}
|
|
|
|
/// <summary>Verifies that DiscoverAsync rejects null builder argument.</summary>
|
|
[Fact]
|
|
public void DiscoverAsync_rejects_null_builder()
|
|
{
|
|
using var drv = new OpcUaClientDriver(new OpcUaClientDriverOptions(), "opcua-disco");
|
|
Should.ThrowAsync<ArgumentNullException>(async () =>
|
|
await drv.DiscoverAsync(null!, TestContext.Current.CancellationToken));
|
|
}
|
|
|
|
/// <summary>Verifies that discovery configuration has sensible defaults.</summary>
|
|
[Fact]
|
|
public void Discovery_caps_are_sensible_defaults()
|
|
{
|
|
var opts = new OpcUaClientDriverOptions();
|
|
opts.MaxDiscoveredNodes.ShouldBe(10_000, "bounds memory on runaway servers without clipping normal models");
|
|
opts.MaxBrowseDepth.ShouldBe(10, "deep enough for realistic info models; shallow enough for cycle safety");
|
|
opts.BrowseRoot.ShouldBeNull("null = default to ObjectsFolder i=85");
|
|
}
|
|
|
|
/// <summary>Test builder that provides no-op implementations for discovery tests.</summary>
|
|
private sealed class NullAddressSpaceBuilder : IAddressSpaceBuilder
|
|
{
|
|
/// <inheritdoc />
|
|
public IAddressSpaceBuilder Folder(string browseName, string displayName) => this;
|
|
|
|
/// <inheritdoc />
|
|
public IVariableHandle Variable(string browseName, string displayName, DriverAttributeInfo attributeInfo)
|
|
=> new StubHandle();
|
|
|
|
/// <inheritdoc />
|
|
public void AddProperty(string browseName, DriverDataType dataType, object? value) { }
|
|
|
|
/// <summary>No-op alarm condition attachment.</summary>
|
|
/// <param name="sourceVariable">The source variable handle.</param>
|
|
/// <param name="alarmName">The alarm name.</param>
|
|
/// <param name="alarmInfo">The alarm attribute information.</param>
|
|
public void AttachAlarmCondition(IVariableHandle sourceVariable, string alarmName, DriverAttributeInfo alarmInfo) { }
|
|
|
|
/// <summary>Stub variable handle for testing.</summary>
|
|
private sealed class StubHandle : IVariableHandle
|
|
{
|
|
/// <inheritdoc />
|
|
public string FullReference => "stub";
|
|
|
|
/// <inheritdoc />
|
|
public IAlarmConditionSink MarkAsAlarmCondition(AlarmConditionInfo info) => throw new NotSupportedException();
|
|
}
|
|
}
|
|
}
|