Linter/formatter pass across the full codebase. Restores required partial keyword on AXAML code-behind classes that the formatter incorrectly removed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
93 lines
3.1 KiB
C#
93 lines
3.1 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.LmxOpcUa.Client.CLI.Commands;
|
|
using ZB.MOM.WW.LmxOpcUa.Client.CLI.Tests.Fakes;
|
|
using ZB.MOM.WW.LmxOpcUa.Client.Shared.Models;
|
|
|
|
namespace ZB.MOM.WW.LmxOpcUa.Client.CLI.Tests;
|
|
|
|
public class RedundancyCommandTests
|
|
{
|
|
[Fact]
|
|
public async Task Execute_PrintsRedundancyInfo()
|
|
{
|
|
var fakeService = new FakeOpcUaClientService
|
|
{
|
|
RedundancyInfoResult = new RedundancyInfo(
|
|
"Hot", 250, ["urn:server:primary", "urn:server:secondary"], "urn:app:myserver")
|
|
};
|
|
var factory = new FakeOpcUaClientServiceFactory(fakeService);
|
|
var command = new RedundancyCommand(factory)
|
|
{
|
|
Url = "opc.tcp://localhost:4840"
|
|
};
|
|
|
|
using var console = TestConsoleHelper.CreateConsole();
|
|
await command.ExecuteAsync(console);
|
|
|
|
var output = TestConsoleHelper.GetOutput(console);
|
|
output.ShouldContain("Redundancy Mode: Hot");
|
|
output.ShouldContain("Service Level: 250");
|
|
output.ShouldContain("Server URIs:");
|
|
output.ShouldContain(" - urn:server:primary");
|
|
output.ShouldContain(" - urn:server:secondary");
|
|
output.ShouldContain("Application URI: urn:app:myserver");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Execute_NoServerUris_OmitsUriSection()
|
|
{
|
|
var fakeService = new FakeOpcUaClientService
|
|
{
|
|
RedundancyInfoResult = new RedundancyInfo(
|
|
"None", 100, [], "urn:app:standalone")
|
|
};
|
|
var factory = new FakeOpcUaClientServiceFactory(fakeService);
|
|
var command = new RedundancyCommand(factory)
|
|
{
|
|
Url = "opc.tcp://localhost:4840"
|
|
};
|
|
|
|
using var console = TestConsoleHelper.CreateConsole();
|
|
await command.ExecuteAsync(console);
|
|
|
|
var output = TestConsoleHelper.GetOutput(console);
|
|
output.ShouldContain("Redundancy Mode: None");
|
|
output.ShouldContain("Service Level: 100");
|
|
output.ShouldNotContain("Server URIs:");
|
|
output.ShouldContain("Application URI: urn:app:standalone");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Execute_CallsGetRedundancyInfo()
|
|
{
|
|
var fakeService = new FakeOpcUaClientService();
|
|
var factory = new FakeOpcUaClientServiceFactory(fakeService);
|
|
var command = new RedundancyCommand(factory)
|
|
{
|
|
Url = "opc.tcp://localhost:4840"
|
|
};
|
|
|
|
using var console = TestConsoleHelper.CreateConsole();
|
|
await command.ExecuteAsync(console);
|
|
|
|
fakeService.GetRedundancyInfoCalled.ShouldBeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Execute_DisconnectsInFinally()
|
|
{
|
|
var fakeService = new FakeOpcUaClientService();
|
|
var factory = new FakeOpcUaClientServiceFactory(fakeService);
|
|
var command = new RedundancyCommand(factory)
|
|
{
|
|
Url = "opc.tcp://localhost:4840"
|
|
};
|
|
|
|
using var console = TestConsoleHelper.CreateConsole();
|
|
await command.ExecuteAsync(console);
|
|
|
|
fakeService.DisconnectCalled.ShouldBeTrue();
|
|
fakeService.DisposeCalled.ShouldBeTrue();
|
|
}
|
|
} |