using System.CommandLine;
using ZB.MOM.WW.ScadaBridge.CLI.Commands;
namespace ZB.MOM.WW.ScadaBridge.CLI.Tests;
///
/// Regression tests for the --format option, which 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
{
/// Verifies that the format option accepts each supported value.
/// The format value supplied to the option.
[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);
}
/// Verifies that the format option rejects unsupported values.
/// The unsupported format value supplied to the option.
[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);
}
}