45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System.CommandLine;
|
|
using ScadaLink.CLI.Commands;
|
|
|
|
namespace ScadaLink.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);
|
|
}
|
|
}
|