Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Components/AlarmStateBadgesTests.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
Comment/XML-doc changes only:
- add summaries to ~10k test methods, fixtures, fakes and helpers
  (+ <param> on theories, <returns> on async Task methods,
  <inheritdoc/> on interface implementations the checker can resolve)
- strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N,
  #NN, Component-0NN) from comments, keeping the explanatory text;
  reword false positives in comments only
- real docs on fakes implementing BCL/library interfaces
  (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime)
- reword the last 5 src/ false positives (CWE-1236, failures-1,
  year-0001, M365)

Only non-comment edits: four one-line nested classes split across lines
so members can carry docs. Build 0 errors / 0 warnings.
2026-10-07 15:05:49 -04:00

60 lines
2.1 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>. 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),
};
/// <summary>Verifies that the state, kind, sub-state, severity and level badges are rendered.</summary>
[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 0–1000 scale.
Assert.Contains("sev 700", cut.Markup);
// HiLo level badge label.
Assert.Contains("Hi", cut.Markup);
}
}