Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/Adapters/OpcUaDataConnectionBrowseTests.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
Comment/XML-doc changes only:
- add summaries to ~10k test methods, fixtures, fakes and helpers
  (+ <param> on theories, <returns> on async Task methods,
  <inheritdoc/> on interface implementations the checker can resolve)
- strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N,
  #NN, Component-0NN) from comments, keeping the explanatory text;
  reword false positives in comments only
- real docs on fakes implementing BCL/library interfaces
  (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime)
- reword the last 5 src/ false positives (CWE-1236, failures-1,
  year-0001, M365)

Only non-comment edits: four one-line nested classes split across lines
so members can carry docs. Build 0 errors / 0 warnings.
2026-10-07 15:05:49 -04:00

44 lines
1.9 KiB
C#

using Microsoft.Extensions.Logging.Abstractions;
using NSubstitute;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Protocol;
using ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Adapters;
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests.Adapters;
/// <summary>
/// <see cref="OpcUaDataConnection"/> implements
/// <see cref="IBrowsableDataConnection"/> as a one-line forwarder onto the
/// underlying <see cref="IOpcUaClient"/>. This guards that wiring — the
/// adapter must not add its own browse semantics; all browse behaviour lives
/// in the client (and is covered by RealOpcUaClient's own tests).
/// </summary>
public class OpcUaDataConnectionBrowseTests
{
/// <summary>Verifies that browsing children is forwarded to the underlying OPC UA client.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task BrowseChildrenAsync_ForwardsToUnderlyingClient()
{
var client = Substitute.For<IOpcUaClient>();
var factory = Substitute.For<IOpcUaClientFactory>();
factory.Create().Returns(client);
client.IsConnected.Returns(true);
var expected = new BrowseChildrenResult(
new[] { new BrowseNode("ns=2;s=X", "X", BrowseNodeClass.Variable, false) },
Truncated: false);
client.BrowseChildrenAsync("ns=2;s=Parent", Arg.Any<string?>(), Arg.Any<CancellationToken>())
.Returns(expected);
var adapter = new OpcUaDataConnection(factory, NullLogger<OpcUaDataConnection>.Instance);
// ConnectAsync installs the IOpcUaClient instance on the adapter; the
// forwarder dereferences that field directly.
await adapter.ConnectAsync(new Dictionary<string, string>());
var actual = await adapter.BrowseChildrenAsync("ns=2;s=Parent");
Assert.Same(expected, actual);
await client.Received(1).BrowseChildrenAsync("ns=2;s=Parent", Arg.Any<string?>(), Arg.Any<CancellationToken>());
}
}