feat(transport): export site/instance selection end-to-end via CLI + ManagementActor (M8 B4)

This commit is contained in:
Joseph Doherty
2026-06-18 06:14:39 -04:00
parent d7dae24355
commit bdbf5cdab0
16 changed files with 450 additions and 12 deletions
@@ -1,3 +1,4 @@
using System.CommandLine;
using ZB.MOM.WW.ScadaBridge.CLI.Commands;
namespace ZB.MOM.WW.ScadaBridge.CLI.Tests.Commands;
@@ -91,4 +92,49 @@ public class BundleCommandsStreamingTests : IDisposable
{
Assert.Throws<ArgumentException>(() => BundleCommands.StreamBase64ToFile("AAAA", string.Empty));
}
// ---- M8 (B4): --sites / --instances comma-split + flag parsing ----------
[Fact]
public void ParseNameList_CommaSeparated_SplitsAndTrims()
{
var result = BundleCommands.ParseNameList(" North-01 , East-02 ,West-03 ");
Assert.NotNull(result);
Assert.Equal(new[] { "North-01", "East-02", "West-03" }, result);
}
[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void ParseNameList_NullOrBlank_ReturnsNull(string? token)
{
Assert.Null(BundleCommands.ParseNameList(token));
}
[Fact]
public void ParseNameList_EmptyEntries_AreDropped()
{
var result = BundleCommands.ParseNameList("a,,b, ,c");
Assert.Equal(new[] { "a", "b", "c" }, result);
}
[Fact]
public void BundleExport_SitesAndInstancesFlags_ParseWithoutError()
{
var url = new Option<string>("--url") { Recursive = true };
var format = new Option<string>("--format") { Recursive = true };
var username = new Option<string>("--username") { Recursive = true };
var password = new Option<string>("--password") { Recursive = true };
var bundle = BundleCommands.Build(url, format, username, password);
var parse = bundle.Parse(new[]
{
"export", "--output", "/tmp/out.scadabundle",
"--sites", "NORTH-01,East Plant",
"--instances", "NORTH-01.Pump1,NORTH-01.Pump2",
});
Assert.Empty(parse.Errors);
}
}