Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.CLI.Tests/Commands/SecuredWriteListCommandTests.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
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.
2026-10-07 15:05:49 -04:00

66 lines
2.6 KiB
C#

using System.CommandLine;
using ZB.MOM.WW.ScadaBridge.CLI.Commands;
namespace ZB.MOM.WW.ScadaBridge.CLI.Tests.Commands;
/// <summary>
/// <c>secured-write list</c> must expose <c>--skip</c>
/// / <c>--take</c> offset-paging options alongside the <c>--status</c> / <c>--site</c>
/// filters, and map them onto <see cref="Commons.Messages.Management.ListSecuredWritesCommand"/>.
/// Omitting the paging flags preserves the historical unpaged default (skip 0, take 200).
/// </summary>
public class SecuredWriteListCommandTests
{
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() => SecuredWriteCommands.Build(Url, Format, Username, Password);
private static Command List() => Group().Subcommands.Single(c => c.Name == "list");
private static Option? FindOption(Command command, string name)
=> command.Options.SingleOrDefault(o => o.Name == name);
/// <summary>Verifies that the list command exposes the skip and take options.</summary>
[Fact]
public void List_HasSkipAndTakeOptions()
{
var list = List();
Assert.NotNull(FindOption(list, "--skip"));
Assert.NotNull(FindOption(list, "--take"));
}
/// <summary>Verifies that the list command parses skip, take and filters and forwards them to the command.</summary>
[Fact]
public void List_ParsesSkipTakeAndFilters_ForwardsToCommand()
{
var parse = Group().Parse(new[]
{
"list", "--status", "Pending", "--site", "SITE1", "--skip", "10", "--take", "25",
});
Assert.Empty(parse.Errors);
var command = SecuredWriteCommands.BuildListCommand(parse);
Assert.Equal("Pending", command.Status);
Assert.Equal("SITE1", command.SiteId);
Assert.Equal(10, command.Skip);
Assert.Equal(25, command.Take);
}
/// <summary>Verifies that omitting the paging options uses the unpaged defaults.</summary>
[Fact]
public void List_OmittedPaging_UsesUnpagedDefaults()
{
var parse = Group().Parse(new[] { "list" });
Assert.Empty(parse.Errors);
var command = SecuredWriteCommands.BuildListCommand(parse);
Assert.Null(command.Status);
Assert.Null(command.SiteId);
Assert.Equal(0, command.Skip);
Assert.Equal(200, command.Take);
}
}