Add cross-platform OPC UA client stack: shared library, CLI tool, and Avalonia UI

Implements Client.Shared (IOpcUaClientService with connection lifecycle, failover,
browse, read/write, subscriptions, alarms, history, redundancy), Client.CLI (8 CliFx
commands mirroring tools/opcuacli-dotnet), and Client.UI (Avalonia desktop app with
tree browser, read/write, subscriptions, alarms, and history tabs). All three target
.NET 10 and are covered by 249 unit tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-03-30 15:49:42 -04:00
parent 50b85d41bd
commit a2883b82d9
109 changed files with 8571 additions and 0 deletions

View File

@@ -0,0 +1,110 @@
using Shouldly;
using Xunit;
using ZB.MOM.WW.LmxOpcUa.Client.Shared.Helpers;
namespace ZB.MOM.WW.LmxOpcUa.Client.Shared.Tests.Helpers;
public class FailoverUrlParserTests
{
[Fact]
public void Parse_CsvNull_ReturnsPrimaryOnly()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840", (string?)null);
result.ShouldBe(new[] { "opc.tcp://primary:4840" });
}
[Fact]
public void Parse_CsvEmpty_ReturnsPrimaryOnly()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840", "");
result.ShouldBe(new[] { "opc.tcp://primary:4840" });
}
[Fact]
public void Parse_CsvWhitespace_ReturnsPrimaryOnly()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840", " ");
result.ShouldBe(new[] { "opc.tcp://primary:4840" });
}
[Fact]
public void Parse_SingleFailover_ReturnsBoth()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840", "opc.tcp://backup:4840");
result.ShouldBe(new[] { "opc.tcp://primary:4840", "opc.tcp://backup:4840" });
}
[Fact]
public void Parse_MultipleFailovers_ReturnsAll()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840", "opc.tcp://backup1:4840,opc.tcp://backup2:4840");
result.ShouldBe(new[] { "opc.tcp://primary:4840", "opc.tcp://backup1:4840", "opc.tcp://backup2:4840" });
}
[Fact]
public void Parse_TrimsWhitespace()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840", " opc.tcp://backup:4840 ");
result.ShouldBe(new[] { "opc.tcp://primary:4840", "opc.tcp://backup:4840" });
}
[Fact]
public void Parse_DeduplicatesPrimaryInFailoverList()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840", "opc.tcp://primary:4840,opc.tcp://backup:4840");
result.ShouldBe(new[] { "opc.tcp://primary:4840", "opc.tcp://backup:4840" });
}
[Fact]
public void Parse_DeduplicatesCaseInsensitive()
{
var result = FailoverUrlParser.Parse("opc.tcp://Primary:4840", "opc.tcp://primary:4840");
result.ShouldBe(new[] { "opc.tcp://Primary:4840" });
}
[Fact]
public void Parse_ArrayNull_ReturnsPrimaryOnly()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840", (string[]?)null);
result.ShouldBe(new[] { "opc.tcp://primary:4840" });
}
[Fact]
public void Parse_ArrayEmpty_ReturnsPrimaryOnly()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840", Array.Empty<string>());
result.ShouldBe(new[] { "opc.tcp://primary:4840" });
}
[Fact]
public void Parse_ArrayWithUrls_ReturnsAll()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840",
new[] { "opc.tcp://backup1:4840", "opc.tcp://backup2:4840" });
result.ShouldBe(new[] { "opc.tcp://primary:4840", "opc.tcp://backup1:4840", "opc.tcp://backup2:4840" });
}
[Fact]
public void Parse_ArrayDeduplicates()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840",
new[] { "opc.tcp://primary:4840", "opc.tcp://backup:4840" });
result.ShouldBe(new[] { "opc.tcp://primary:4840", "opc.tcp://backup:4840" });
}
[Fact]
public void Parse_ArrayTrimsWhitespace()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840",
new[] { " opc.tcp://backup:4840 " });
result.ShouldBe(new[] { "opc.tcp://primary:4840", "opc.tcp://backup:4840" });
}
[Fact]
public void Parse_ArraySkipsNullAndEmpty()
{
var result = FailoverUrlParser.Parse("opc.tcp://primary:4840",
new[] { null!, "", "opc.tcp://backup:4840" });
result.ShouldBe(new[] { "opc.tcp://primary:4840", "opc.tcp://backup:4840" });
}
}