513fa1aa16
Comment/XML-doc changes only: - add summaries to ~10k test methods, fixtures, fakes and helpers (+ <param> on theories, <returns> on async Task methods, <inheritdoc/> on interface implementations the checker can resolve) - strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N, #NN, Component-0NN) from comments, keeping the explanatory text; reword false positives in comments only - real docs on fakes implementing BCL/library interfaces (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime) - reword the last 5 src/ false positives (CWE-1236, failures-1, year-0001, M365) Only non-comment edits: four one-line nested classes split across lines so members can carry docs. Build 0 errors / 0 warnings.
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using System.CommandLine;
|
|
using ZB.MOM.WW.ScadaBridge.CLI.Commands;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.CLI.Tests;
|
|
|
|
/// <summary>
|
|
/// Regression tests for the <c>--format</c> option, which 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
|
|
{
|
|
/// <summary>Verifies that the format option accepts each supported value.</summary>
|
|
/// <param name="value">The format value supplied to the option.</param>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>Verifies that the format option rejects unsupported values.</summary>
|
|
/// <param name="value">The unsupported format value supplied to the option.</param>
|
|
[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);
|
|
}
|
|
}
|