From 8980adceb33cb5dc3fc1d3cfb4fd0cf58f367c36 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 16 Jun 2026 18:19:29 -0400 Subject: [PATCH] test(client-ui): track Shelve/Confirm calls + exceptions in FakeOpcUaClientService --- .../Fakes/FakeOpcUaClientService.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/Client/ZB.MOM.WW.OtOpcUa.Client.UI.Tests/Fakes/FakeOpcUaClientService.cs b/tests/Client/ZB.MOM.WW.OtOpcUa.Client.UI.Tests/Fakes/FakeOpcUaClientService.cs index e8cbbdbb..d1fef1a9 100644 --- a/tests/Client/ZB.MOM.WW.OtOpcUa.Client.UI.Tests/Fakes/FakeOpcUaClientService.cs +++ b/tests/Client/ZB.MOM.WW.OtOpcUa.Client.UI.Tests/Fakes/FakeOpcUaClientService.cs @@ -265,21 +265,39 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService /// Gets or sets the status code returned by confirmation operations in UI tests. public StatusCode ConfirmResult { get; set; } = StatusCodes.Good; + /// Gets or sets the exception thrown to simulate alarm confirmation failures in the UI. + public Exception? ConfirmException { get; set; } + /// Gets the number of times ConfirmAlarmAsync has been called. + public int ConfirmCallCount { get; private set; } + /// Gets the (conditionNodeId, eventId, comment) of the last ConfirmAlarmAsync call. + public (string ConditionNodeId, byte[] EventId, string Comment)? LastConfirmCall { get; private set; } /// public Task ConfirmAlarmAsync(string conditionNodeId, byte[] eventId, string comment, CancellationToken ct = default) { + ConfirmCallCount++; + LastConfirmCall = (conditionNodeId, eventId, comment); + if (ConfirmException != null) throw ConfirmException; return Task.FromResult(ConfirmResult); } /// Gets or sets the status code returned by shelve operations in UI tests. public StatusCode ShelveResult { get; set; } = StatusCodes.Good; + /// Gets or sets the exception thrown to simulate alarm shelve failures in the UI. + public Exception? ShelveException { get; set; } + /// Gets the number of times ShelveAlarmAsync has been called. + public int ShelveCallCount { get; private set; } + /// Gets the (conditionNodeId, kind, shelvingTimeSeconds) of the last ShelveAlarmAsync call. + public (string ConditionNodeId, ShelveKind Kind, double ShelvingTimeSeconds)? LastShelveCall { get; private set; } /// public Task ShelveAlarmAsync(string conditionNodeId, ShelveKind kind, double shelvingTimeSeconds = 0, CancellationToken ct = default) { + ShelveCallCount++; + LastShelveCall = (conditionNodeId, kind, shelvingTimeSeconds); + if (ShelveException != null) throw ShelveException; return Task.FromResult(ShelveResult); }