using System.CommandLine;
using ZB.MOM.WW.ScadaBridge.CLI.Commands;

namespace ZB.MOM.WW.ScadaBridge.CLI.Tests;

/// <summary>
/// Regression tests for CLI-008 — the <c>--format</c> option previously accepted any
/// string, so a typo like <c>--format tabel</c> silently fell through to JSON output
/// with no feedback. The option must reject values outside {json, table} with a parse
/// error.
/// </summary>
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);
    }
}
