- Driver.TwinCAT.Cli-001: TwinCATCommandBase.Validate rejects non-positive TimeoutMs / IntervalMs and AmsPort outside 1..65535; ExecuteAsync calls it first. - Driver.TwinCAT.Cli-002: SubscribeCommand serialises every WriteLine through a writeLock to remove the notification-callback vs banner interleave risk. - Driver.TwinCAT.Cli-003: SubscribeCommand.DescribeMechanism derives the banner label from the returned ISubscriptionHandle.DiagnosticId so it can't disagree with what the driver actually did. - Driver.TwinCAT.Cli-004: introduced TwinCATTagCommandBase carrying --poll-only + BuildOptions; BrowseCommand stays on the slimmer TwinCATCommandBase so --poll-only no longer surfaces in browse --help. - Driver.TwinCAT.Cli-005: ProbeCommand --type now carries the 't' short alias to match the other commands. - Driver.TwinCAT.Cli-006: 35 new tests covering Gateway / AmsAddress parse / BuildOptions / PollOnly / browse-helpers / probe-alias / mechanism derivation. - Driver.TwinCAT.Cli-007: replaced the empty-init <inheritdoc/> with an explicit summary warning future maintainers about the no-op init. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
using ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Cli.Commands;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Cli.Tests;
|
|
|
|
/// <summary>
|
|
/// Driver.TwinCAT.Cli-003: the subscribe banner mechanism label is derived from the
|
|
/// <see cref="ISubscriptionHandle.DiagnosticId"/> the driver actually returned, not from
|
|
/// the <c>--poll-only</c> flag. That way the banner cannot disagree with what the driver
|
|
/// did even if a future fallback path lands the subscription somewhere unexpected.
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public sealed class SubscribeCommandMechanismTests
|
|
{
|
|
private sealed record StubHandle(string DiagnosticId) : ISubscriptionHandle;
|
|
|
|
[Theory]
|
|
[InlineData("twincat-native-sub-1")]
|
|
[InlineData("twincat-native-sub-42")]
|
|
[InlineData("twincat-native-sub-9223372036854775807")]
|
|
public void DescribeMechanism_returns_ADS_notification_for_native_handle(string diagId)
|
|
{
|
|
SubscribeCommand.DescribeMechanism(new StubHandle(diagId)).ShouldBe("ADS notification");
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("pollgroup-1")]
|
|
[InlineData("modbus-poll-7")]
|
|
[InlineData("")]
|
|
[InlineData("TWINCAT-NATIVE-SUB-1")] // ordinal comparison — uppercase prefix does NOT match.
|
|
public void DescribeMechanism_returns_polling_for_anything_else(string diagId)
|
|
{
|
|
SubscribeCommand.DescribeMechanism(new StubHandle(diagId)).ShouldBe("polling");
|
|
}
|
|
}
|