using System.CommandLine; using ScadaLink.CLI.Commands; namespace ScadaLink.CLI.Tests; /// /// Regression tests for CLI-008 — the --format option previously accepted any /// string, so a typo like --format tabel silently fell through to JSON output /// with no feedback. The option must reject values outside {json, table} with a parse /// error. /// public class FormatOptionValidationTests { [Theory] [InlineData("json")] [InlineData("table")] public void FormatOption_AcceptsValidValues(string value) { var formatOption = CliOptions.CreateFormatOption(); var root = new RootCommand(); root.Add(formatOption); var result = root.Parse(new[] { "--format", value }); Assert.Empty(result.Errors); } [Theory] [InlineData("tabel")] [InlineData("xml")] [InlineData("yaml")] [InlineData("")] [InlineData("JSON")] // case-sensitive: documented values are lowercase public void FormatOption_RejectsInvalidValues(string value) { var formatOption = CliOptions.CreateFormatOption(); var root = new RootCommand(); root.Add(formatOption); var result = root.Parse(new[] { "--format", value }); Assert.NotEmpty(result.Errors); } }