test(client-ui): cover Confirm missing-ConditionId + Shelve/Confirm exception paths (review)
This commit is contained in:
@@ -342,6 +342,47 @@ public class AlarmsViewModelTests
|
||||
message.ShouldContain("Confirm failed");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that confirming an alarm without a ConditionNodeId is rejected without a service call.</summary>
|
||||
[Fact]
|
||||
public async Task ConfirmAlarm_MissingConditionNodeId_Fails_NoServiceCall()
|
||||
{
|
||||
_vm.IsConnected = true;
|
||||
var alarm = BuildAlarm(conditionNodeId: null);
|
||||
|
||||
var (ok, _) = await _vm.ConfirmAlarmAsync(alarm, "note");
|
||||
|
||||
ok.ShouldBeFalse();
|
||||
_service.ConfirmCallCount.ShouldBe(0);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a transport exception from ShelveAlarmAsync is caught and surfaced as an error message.</summary>
|
||||
[Fact]
|
||||
public async Task ShelveAlarm_ServiceThrows_ReturnsError()
|
||||
{
|
||||
_vm.IsConnected = true;
|
||||
_service.ShelveException = new InvalidOperationException("transport error");
|
||||
var alarm = BuildAlarm();
|
||||
|
||||
var (ok, message) = await _vm.ShelveAlarmAsync(alarm, ShelveKind.OneShot, 0);
|
||||
|
||||
ok.ShouldBeFalse();
|
||||
message.ShouldContain("Error");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a transport exception from ConfirmAlarmAsync is caught and surfaced as an error message.</summary>
|
||||
[Fact]
|
||||
public async Task ConfirmAlarm_ServiceThrows_ReturnsError()
|
||||
{
|
||||
_vm.IsConnected = true;
|
||||
_service.ConfirmException = new InvalidOperationException("transport error");
|
||||
var alarm = BuildAlarm();
|
||||
|
||||
var (ok, message) = await _vm.ConfirmAlarmAsync(alarm, "note");
|
||||
|
||||
ok.ShouldBeFalse();
|
||||
message.ShouldContain("Error");
|
||||
}
|
||||
|
||||
// --- CanShelve / CanConfirm predicates ---
|
||||
|
||||
/// <summary>Verifies CanShelve is true when a ConditionNodeId is present.</summary>
|
||||
|
||||
Reference in New Issue
Block a user