Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Components/AlarmStateBadgesTests.cs
T

59 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Bunit;
using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Shared;
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Streaming;
using ZB.MOM.WW.ScadaBridge.Commons.Types.Alarms;
using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Components;
/// <summary>
/// Covers the <c>AlarmStateBadges</c> shared component lifted out of
/// <c>DebugView</c> (M7-T13 prep). The badge cluster must render identically
/// wherever it is hosted, so these tests pin the rendered markup: state badge
/// class, kind label, native sub-state badges, severity, and HiLo level.
/// </summary>
public class AlarmStateBadgesTests : BunitContext
{
private static AlarmStateChanged ActiveNativeHighUnacked() => new(
InstanceUniqueName: "Tank01",
AlarmName: "Tank01.Level.HiHi",
State: AlarmState.Active,
Priority: 700,
Timestamp: DateTimeOffset.UtcNow)
{
Kind = AlarmKind.NativeOpcUa,
Level = AlarmLevel.High,
Condition = new AlarmConditionState(
Active: true,
Acknowledged: false,
Confirmed: null,
Shelve: AlarmShelveState.Unshelved,
Suppressed: false,
Severity: 700),
};
[Fact]
public void Renders_StateKindSubStateSeverityAndLevel_Badges()
{
var alarm = ActiveNativeHighUnacked();
var cut = Render<AlarmStateBadges>(p => p.Add(c => c.Alarm, alarm));
// State badge: Active condition tinted danger.
Assert.Contains("bg-danger", cut.Markup);
Assert.Contains("Active", cut.Markup);
// Kind badge label for a native OPC UA alarm.
Assert.Contains("OPC UA", cut.Markup);
// Native sub-state badge: active + unacknowledged.
Assert.Contains("Unacked", cut.Markup);
// Severity span on the unified 01000 scale.
Assert.Contains("sev 700", cut.Markup);
// HiLo level badge label.
Assert.Contains("Hi", cut.Markup);
}
}