64e3fbe035
v2-ci / build (push) Failing after 1m43s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
Adds <summary>, <param>, <typeparam>, and <inheritdoc/> tags to public members surfaced by commentchecker — resolves 5,847 of 5,869 issues (99.6%) across three /fixdocs passes.
95 lines
3.1 KiB
C#
95 lines
3.1 KiB
C#
using CliFx.Attributes;
|
|
using CliFx.Infrastructure;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Driver.FOCAS;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Cli.Tests;
|
|
|
|
/// <summary>
|
|
/// Covers <see cref="FocasCommandBase.BuildOptions"/> — the pure, deterministic mapping
|
|
/// from the base's CNC host/port/series/timeout flags onto a
|
|
/// <c>FocasDriverOptions</c>. The CLI is one-shot so the background connectivity probe
|
|
/// must be disabled.
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public sealed class FocasCommandBaseBuildOptionsTests
|
|
{
|
|
[Command("noop-test", Description = "Test-only probe of FocasCommandBase.BuildOptions.")]
|
|
private sealed class ProbeOnly : FocasCommandBase
|
|
{
|
|
/// <inheritdoc />
|
|
public override ValueTask ExecuteAsync(IConsole console) => default;
|
|
/// <summary>Invokes the BuildOptions method with the given tags.</summary>
|
|
/// <param name="tags">The list of tag definitions.</param>
|
|
/// <returns>The built driver options.</returns>
|
|
public FocasDriverOptions Invoke(IReadOnlyList<FocasTagDefinition> tags) => BuildOptions(tags);
|
|
}
|
|
|
|
/// <summary>Verifies that BuildOptions disables probe for one-shot CLI runs.</summary>
|
|
[Fact]
|
|
public void BuildOptions_disables_probe_for_one_shot_cli_runs()
|
|
{
|
|
var sut = new ProbeOnly
|
|
{
|
|
CncHost = "10.0.0.5",
|
|
CncPort = 8193,
|
|
Series = FocasCncSeries.ThirtyOne_i,
|
|
TimeoutMs = 5000,
|
|
};
|
|
|
|
var options = sut.Invoke([]);
|
|
|
|
options.Probe.ShouldNotBeNull();
|
|
options.Probe.Enabled.ShouldBeFalse();
|
|
}
|
|
|
|
/// <summary>Verifies that BuildOptions maps TimeoutMs to Timeout TimeSpan.</summary>
|
|
[Fact]
|
|
public void BuildOptions_maps_TimeoutMs_to_Timeout_TimeSpan()
|
|
{
|
|
var sut = new ProbeOnly { CncHost = "h", TimeoutMs = 7500 };
|
|
|
|
var options = sut.Invoke([]);
|
|
|
|
options.Timeout.ShouldBe(TimeSpan.FromMilliseconds(7500));
|
|
}
|
|
|
|
/// <summary>Verifies that BuildOptions flows host, port, and series through.</summary>
|
|
[Fact]
|
|
public void BuildOptions_flows_host_port_series_through()
|
|
{
|
|
var sut = new ProbeOnly
|
|
{
|
|
CncHost = "cnc.shop.local",
|
|
CncPort = 8194,
|
|
Series = FocasCncSeries.Zero_i_F,
|
|
TimeoutMs = 3000,
|
|
};
|
|
|
|
var options = sut.Invoke([]);
|
|
|
|
options.Devices.Count.ShouldBe(1);
|
|
options.Devices[0].HostAddress.ShouldBe("focas://cnc.shop.local:8194");
|
|
options.Devices[0].Series.ShouldBe(FocasCncSeries.Zero_i_F);
|
|
}
|
|
|
|
/// <summary>Verifies that BuildOptions forwards tag list verbatim.</summary>
|
|
[Fact]
|
|
public void BuildOptions_forwards_tag_list_verbatim()
|
|
{
|
|
var sut = new ProbeOnly { CncHost = "h" };
|
|
var tag = new FocasTagDefinition(
|
|
Name: "t",
|
|
DeviceHostAddress: "focas://h:8193",
|
|
Address: "R100",
|
|
DataType: FocasDataType.Int16,
|
|
Writable: false);
|
|
|
|
var options = sut.Invoke([tag]);
|
|
|
|
options.Tags.Count.ShouldBe(1);
|
|
options.Tags[0].ShouldBeSameAs(tag);
|
|
}
|
|
}
|