using Shouldly; using Xunit; namespace ZB.MOM.WW.OtOpcUa.Driver.S7.Cli.Tests; /// /// Driver.S7.Cli-007: the S7 subscribe command — a near-verbatim copy of the Modbus /// subscribe command — must keep the comment that explains why OnDataChange /// uses console.Output.WriteLine (synchronous, on a driver background thread) /// instead of System.Console or the async WriteLineAsync. The rationale /// is non-obvious to a reader and the Modbus copy carries it; the S7 copy must too. /// [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"); } }