fix(adminui,cli): /raw device-name placeholder + no-prerender tree, CLI read prints Bad status (#577)
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
@@ -99,4 +99,45 @@ public class ReadCommandTests
|
||||
fakeService.DisconnectCalled.ShouldBeTrue();
|
||||
fakeService.DisposeCalled.ShouldBeTrue();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A Bad node status is printed, not thrown (#577).</summary>
|
||||
[Fact]
|
||||
public async Task Execute_PrintsStatusCodeWhenTheReadFailsWithABadStatus()
|
||||
{
|
||||
var fakeService = new FakeOpcUaClientService
|
||||
{
|
||||
ReadException = new ServiceResultException(StatusCodes.BadNodeIdUnknown)
|
||||
};
|
||||
var command = new ReadCommand(new FakeOpcUaClientServiceFactory(fakeService))
|
||||
{
|
||||
Url = "opc.tcp://localhost:4840",
|
||||
NodeId = "ns=2;s=Missing"
|
||||
};
|
||||
|
||||
using var console = TestConsoleHelper.CreateConsole();
|
||||
await command.ExecuteAsync(console); // must not throw
|
||||
|
||||
var output = TestConsoleHelper.GetOutput(console);
|
||||
output.ShouldContain("Node: ns=2;s=Missing");
|
||||
output.ShouldContain("BadNodeIdUnknown");
|
||||
fakeService.DisconnectCalled.ShouldBeTrue(); // positive control: the finally still ran
|
||||
}
|
||||
|
||||
/// <summary>A session-level failure is still an error, not a printed status.</summary>
|
||||
[Fact]
|
||||
public async Task Execute_StillThrowsOnASessionLevelFailure()
|
||||
{
|
||||
var fakeService = new FakeOpcUaClientService
|
||||
{
|
||||
ReadException = new ServiceResultException(StatusCodes.BadConnectionClosed)
|
||||
};
|
||||
var command = new ReadCommand(new FakeOpcUaClientServiceFactory(fakeService))
|
||||
{
|
||||
Url = "opc.tcp://localhost:4840",
|
||||
NodeId = "ns=2;s=Any"
|
||||
};
|
||||
|
||||
using var console = TestConsoleHelper.CreateConsole();
|
||||
await Should.ThrowAsync<ServiceResultException>(async () => await command.ExecuteAsync(console));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user