using System.Reflection; using CliFx.Attributes; using Shouldly; using Xunit; using ZB.MOM.WW.OtOpcUa.Driver.AbCip.Cli.Commands; namespace ZB.MOM.WW.OtOpcUa.Driver.AbCip.Cli.Tests; /// /// Verifies that the CLI's help text is consistent with its runtime behaviour — in /// particular that rejected types do not appear as valid options in the option description, /// and that counts stated in CLI metadata are accurate. /// [Trait("Category", "Unit")] public sealed class HelpTextConsistencyTests { /// /// Driver.AbCip.Cli-010 — ReadCommand's --type option description must NOT /// list Structure, because RejectStructure will refuse it at runtime. /// Listing a rejected value in the help text misleads operators. /// [Fact] public void ReadCommand_type_option_description_does_not_list_Structure() { var prop = typeof(ReadCommand).GetProperty( nameof(ReadCommand.DataType), BindingFlags.Public | BindingFlags.Instance) ?? throw new InvalidOperationException("DataType property not found on ReadCommand"); var attr = prop.GetCustomAttribute() ?? throw new InvalidOperationException("CommandOptionAttribute not found on ReadCommand.DataType"); // RejectStructure is called in ReadCommand.ExecuteAsync; listing Structure in the // help text as a valid --type value misleads operators (Driver.AbCip.Cli-010). (attr.Description ?? string.Empty).ShouldNotContain("Structure"); } }