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.
85 lines
3.2 KiB
C#
85 lines
3.2 KiB
C#
using System.CommandLine;
|
|
using ZB.MOM.WW.ScadaBridge.CLI.Commands;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.CLI.Tests.Commands;
|
|
|
|
/// <summary>
|
|
/// <c>external-system create</c> and <c>external-system update</c>
|
|
/// must expose an optional <c>--timeout-seconds</c> (<see cref="int"/>?) flag that
|
|
/// carries the per-system ESG HTTP timeout. Omitting it preserves the existing value
|
|
/// (update) / uses the gateway default (create).
|
|
/// </summary>
|
|
public class ExternalSystemTimeoutOptionTests
|
|
{
|
|
private static readonly Option<string> Url = new("--url") { Recursive = true };
|
|
private static readonly Option<string> Format = new("--format") { Recursive = true };
|
|
private static readonly Option<string> Username = new("--username") { Recursive = true };
|
|
private static readonly Option<string> Password = new("--password") { Recursive = true };
|
|
|
|
private static Command Group() => ExternalSystemCommands.Build(Url, Format, Username, Password);
|
|
|
|
private static Option? FindOption(Command command, string name)
|
|
=> command.Options.SingleOrDefault(o => o.Name == name);
|
|
|
|
/// <summary>Verifies that the create command exposes an optional timeout-seconds option.</summary>
|
|
[Fact]
|
|
public void Create_HasOptionalTimeoutSecondsOption()
|
|
{
|
|
var create = Group().Subcommands.Single(c => c.Name == "create");
|
|
var option = FindOption(create, "--timeout-seconds");
|
|
Assert.NotNull(option);
|
|
Assert.False(option!.Required);
|
|
}
|
|
|
|
/// <summary>Verifies that the update command exposes an optional timeout-seconds option.</summary>
|
|
[Fact]
|
|
public void Update_HasOptionalTimeoutSecondsOption()
|
|
{
|
|
var update = Group().Subcommands.Single(c => c.Name == "update");
|
|
var option = FindOption(update, "--timeout-seconds");
|
|
Assert.NotNull(option);
|
|
Assert.False(option!.Required);
|
|
}
|
|
|
|
/// <summary>Verifies that the create command parses a supplied timeout-seconds value.</summary>
|
|
[Fact]
|
|
public void Create_ParsesTimeoutSecondsValue()
|
|
{
|
|
var parse = Group().Parse(new[]
|
|
{
|
|
"create", "--name", "Sys", "--endpoint-url", "http://x",
|
|
"--auth-type", "none", "--timeout-seconds", "15",
|
|
});
|
|
|
|
Assert.Empty(parse.Errors);
|
|
Assert.Equal(15, parse.GetValue<int?>("--timeout-seconds"));
|
|
}
|
|
|
|
/// <summary>Verifies that the update command parses a supplied timeout-seconds value.</summary>
|
|
[Fact]
|
|
public void Update_ParsesTimeoutSecondsValue()
|
|
{
|
|
var parse = Group().Parse(new[]
|
|
{
|
|
"update", "--id", "7", "--name", "Sys", "--endpoint-url", "http://x",
|
|
"--auth-type", "none", "--timeout-seconds", "20",
|
|
});
|
|
|
|
Assert.Empty(parse.Errors);
|
|
Assert.Equal(20, parse.GetValue<int?>("--timeout-seconds"));
|
|
}
|
|
|
|
/// <summary>Verifies that omitting timeout-seconds on create parses without error.</summary>
|
|
[Fact]
|
|
public void Create_OmittedTimeoutSeconds_ParsesWithoutError()
|
|
{
|
|
var parse = Group().Parse(new[]
|
|
{
|
|
"create", "--name", "Sys", "--endpoint-url", "http://x", "--auth-type", "none",
|
|
});
|
|
|
|
Assert.Empty(parse.Errors);
|
|
Assert.Null(parse.GetValue<int?>("--timeout-seconds"));
|
|
}
|
|
}
|