- Driver.S7.Cli-004: 'await using var driver' is the sole driver disposal path; dropped the redundant explicit await ShutdownAsync from each command's finally. - Driver.S7.Cli-005: deleted the stale empty tests/ZB.MOM.WW.OtOpcUa.Driver.S7.Cli.Tests/ directory (the real test project lives under tests/Drivers/Cli/). - Driver.S7.Cli-006: S7CommandBaseBuildOptionsTests cover the probe toggle, timeout mapping, host/port/CPU/rack/slot wiring, and tag list passthrough. - Driver.S7.Cli-007: re-added the SubscribeCommand handler comment explaining the CliFx IConsole.Output usage and that the poll-thread raises events. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
1.4 KiB
C#
33 lines
1.4 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.S7.Cli.Tests;
|
|
|
|
/// <summary>
|
|
/// Driver.S7.Cli-007: the S7 subscribe command — a near-verbatim copy of the Modbus
|
|
/// subscribe command — must keep the comment that explains why <c>OnDataChange</c>
|
|
/// uses <c>console.Output.WriteLine</c> (synchronous, on a driver background thread)
|
|
/// instead of <c>System.Console</c> or the async <c>WriteLineAsync</c>. The rationale
|
|
/// is non-obvious to a reader and the Modbus copy carries it; the S7 copy must too.
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public sealed class SubscribeCommandConsoleHandlerCommentTests
|
|
{
|
|
[Fact]
|
|
public void SubscribeCommand_explains_why_OnDataChange_uses_console_Output_synchronously()
|
|
{
|
|
var dir = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "ZB.MOM.WW.OtOpcUa.slnx")))
|
|
dir = dir.Parent;
|
|
dir.ShouldNotBeNull();
|
|
var source = File.ReadAllText(Path.Combine(
|
|
dir!.FullName, "src", "Drivers", "Cli", "ZB.MOM.WW.OtOpcUa.Driver.S7.Cli",
|
|
"Commands", "SubscribeCommand.cs"));
|
|
|
|
// The comment must reference the CliFx console abstraction so future copy-pastes
|
|
// do not lose the rationale.
|
|
source.ShouldContain("CliFx console");
|
|
source.ShouldContain("IConsole");
|
|
}
|
|
}
|