fix(driver-abcip-cli): resolve Low code-review findings (Driver.AbCip.Cli-003,004,005,006,007,008)
- Driver.AbCip.Cli-003: SubscribeCommand prints the 'Subscribed' banner BEFORE wiring OnDataChange so the main thread can't interleave its write with the poll-thread handler. - Driver.AbCip.Cli-004: AbCipCommandBase.Timeout and SubscribeCommand validate TimeoutMs / IntervalMs and throw CommandException on non-positive values. - Driver.AbCip.Cli-005: every command now calls FlushLogging() in its finally block. - Driver.AbCip.Cli-006: Timeout init throws NotSupportedException with a pointer at TimeoutMs instead of silently swallowing assignments. - Driver.AbCip.Cli-007: added AbCipCommandBaseTests covering BuildOptions shape, probe / controller-browse / alarm toggles, host address, family selection, tag list passthrough. - Driver.AbCip.Cli-008: rewrote the opening paragraph in docs/Driver.AbCip.Cli.md to credit the six-CLI roster with a pointer at docs/DriverClis.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.AbCip.Cli.Commands;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Driver.AbCip.Cli.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Covers <see cref="SubscribeCommand.ValidateInterval(int)"/> — the guard that
|
||||
/// stops a zero / negative <c>--interval-ms</c> from reaching <c>SubscribeAsync</c>
|
||||
/// as a non-positive <see cref="TimeSpan"/>.
|
||||
/// </summary>
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class SubscribeCommandIntervalTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(0)]
|
||||
[InlineData(-1)]
|
||||
[InlineData(-500)]
|
||||
public void ValidateInterval_rejects_non_positive(int badMs)
|
||||
{
|
||||
var ex = Should.Throw<CliFx.Exceptions.CommandException>(
|
||||
() => SubscribeCommand.ValidateInterval(badMs));
|
||||
ex.Message.ShouldContain("--interval-ms");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(1)]
|
||||
[InlineData(250)]
|
||||
[InlineData(60_000)]
|
||||
public void ValidateInterval_accepts_positive(int goodMs)
|
||||
{
|
||||
Should.NotThrow(() => SubscribeCommand.ValidateInterval(goodMs));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user