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.
87 lines
3.9 KiB
C#
87 lines
3.9 KiB
C#
using System.Linq;
|
|
using System.Reflection;
|
|
using CliFx.Attributes;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Cli.Commands;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Cli.Tests;
|
|
|
|
/// <summary>
|
|
/// Locks in the CLI command-option contract surface area — short aliases and
|
|
/// help-text wording — that the AbLegacy CLI is expected to keep in parity with
|
|
/// its sibling AbCip CLI and with <c>docs/Driver.AbLegacy.Cli.md</c>.
|
|
/// Regression coverage for findings Driver.AbLegacy.Cli-002, -005, -006.
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public sealed class CommandMetadataTests
|
|
{
|
|
private static CommandOptionAttribute GetOption<TCommand>(string propertyName)
|
|
{
|
|
var prop = typeof(TCommand).GetProperty(
|
|
propertyName,
|
|
BindingFlags.Public | BindingFlags.Instance);
|
|
prop.ShouldNotBeNull($"property {propertyName} is missing from {typeof(TCommand).Name}");
|
|
var attr = prop!.GetCustomAttribute<CommandOptionAttribute>();
|
|
attr.ShouldNotBeNull(
|
|
$"property {propertyName} on {typeof(TCommand).Name} lacks [CommandOption]");
|
|
return attr!;
|
|
}
|
|
|
|
// ---------- Driver.AbLegacy.Cli-006 — ProbeCommand --type needs short alias 't' ----------
|
|
|
|
/// <summary>Verifies that ProbeCommand --type has short alias -t.</summary>
|
|
[Fact]
|
|
public void ProbeCommand_type_has_short_alias_t()
|
|
{
|
|
// Parity with read / write / subscribe: --type / -t works everywhere.
|
|
var attr = GetOption<ProbeCommand>(nameof(ProbeCommand.DataType));
|
|
attr.ShortName.ShouldBe('t');
|
|
}
|
|
|
|
/// <summary>Verifies that other commands keep the --type short alias as -t.</summary>
|
|
/// <param name="commandType">The command type to inspect for the --type option.</param>
|
|
/// <param name="propName">The property name of the --type option on the command.</param>
|
|
[Theory]
|
|
[InlineData(typeof(ReadCommand), nameof(ReadCommand.DataType))]
|
|
[InlineData(typeof(WriteCommand), nameof(WriteCommand.DataType))]
|
|
[InlineData(typeof(SubscribeCommand), nameof(SubscribeCommand.DataType))]
|
|
public void Other_commands_keep_type_short_alias_t(System.Type commandType, string propName)
|
|
{
|
|
var prop = commandType.GetProperty(propName, BindingFlags.Public | BindingFlags.Instance);
|
|
prop.ShouldNotBeNull();
|
|
var attr = prop!.GetCustomAttribute<CommandOptionAttribute>();
|
|
attr.ShouldNotBeNull();
|
|
attr!.ShortName.ShouldBe('t');
|
|
}
|
|
|
|
// ---------- Driver.AbLegacy.Cli-002 — WriteCommand --value help lists full bool alias set ----------
|
|
|
|
/// <summary>Verifies that WriteCommand --value help lists the full boolean alias set.</summary>
|
|
[Fact]
|
|
public void WriteCommand_value_help_lists_full_boolean_alias_set()
|
|
{
|
|
// ParseBool accepts true/false, 1/0, on/off, yes/no — the help text must say so
|
|
// (DriverClis.md documents the full alias set as the shared CLI contract).
|
|
var attr = GetOption<WriteCommand>(nameof(WriteCommand.Value));
|
|
attr.Description.ShouldNotBeNull();
|
|
attr.Description!.ShouldContain("true/false", Case.Insensitive);
|
|
attr.Description!.ShouldContain("1/0");
|
|
attr.Description!.ShouldContain("on/off", Case.Insensitive);
|
|
attr.Description!.ShouldContain("yes/no", Case.Insensitive);
|
|
}
|
|
|
|
// ---------- Driver.AbLegacy.Cli-005 — SubscribeCommand --interval-ms help notes 250ms floor ----------
|
|
|
|
/// <summary>Verifies that SubscribeCommand --interval-ms help notes the PollGroupEngine floor.</summary>
|
|
[Fact]
|
|
public void SubscribeCommand_interval_ms_help_notes_PollGroupEngine_floor()
|
|
{
|
|
// Parity with AbCip CLI: operators passing -i 100 deserve a heads-up that
|
|
// PollGroupEngine floors sub-250ms values.
|
|
var attr = GetOption<SubscribeCommand>(nameof(SubscribeCommand.IntervalMs));
|
|
attr.Description.ShouldNotBeNull();
|
|
attr.Description!.ShouldContain("250", Case.Insensitive);
|
|
}
|
|
}
|