513fa1aa16
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.
63 lines
2.7 KiB
C#
63 lines
2.7 KiB
C#
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.Commons.Tests.Messages;
|
|
|
|
public class AlarmStateChangedEnrichmentTests
|
|
{
|
|
/// <summary>Verifies that a default alarm state change is of the computed kind with auto-acknowledge.</summary>
|
|
[Fact]
|
|
public void Defaults_AreComputedKind_WithAutoAck()
|
|
{
|
|
var m = new AlarmStateChanged("inst", "HiAlarm", AlarmState.Active, 700, DateTimeOffset.UnixEpoch);
|
|
Assert.Equal(AlarmKind.Computed, m.Kind);
|
|
Assert.True(m.Condition.Acknowledged); // computed = auto-acked
|
|
Assert.Equal(700, m.Condition.Severity); // severity defaults to Priority
|
|
Assert.True(m.Condition.Active); // derived from State
|
|
Assert.Equal("", m.SourceReference);
|
|
}
|
|
|
|
/// <summary>Verifies that the computed factory maps priority and state onto the message.</summary>
|
|
[Fact]
|
|
public void Factory_ForComputed_MapsPriorityAndState()
|
|
{
|
|
var c = AlarmConditionStateFactory.ForComputed(AlarmState.Normal, priority: 250);
|
|
Assert.False(c.Active);
|
|
Assert.True(c.Acknowledged);
|
|
Assert.Equal(250, c.Severity);
|
|
}
|
|
|
|
// ── MES alarm-status API §6.4: additive AckTime ──
|
|
|
|
/// <summary>Verifies that the acknowledge time defaults to null when using the positional constructor.</summary>
|
|
[Fact]
|
|
public void AckTime_DefaultsToNull_OnThePositionalConstructor()
|
|
{
|
|
// Additive-only evolution: every existing positional construction stays valid and
|
|
// reports no ack time. A computed alarm is auto-acked but has no operator ack
|
|
// event, so null (not the timestamp) is the honest value.
|
|
var m = new AlarmStateChanged("inst", "HiAlarm", AlarmState.Active, 700, DateTimeOffset.UnixEpoch);
|
|
|
|
Assert.True(m.Condition.Acknowledged); // computed = auto-acked…
|
|
Assert.Null(m.AckTime); // …yet still no ack instant
|
|
}
|
|
|
|
/// <summary>Verifies that the acknowledge time round-trips through its init property.</summary>
|
|
[Fact]
|
|
public void AckTime_RoundTripsThroughTheInitProperty()
|
|
{
|
|
var ackedAt = new DateTimeOffset(2026, 8, 1, 12, 0, 0, TimeSpan.Zero);
|
|
|
|
var m = new AlarmStateChanged("inst", "Tank01.Level.HiHi", AlarmState.Active, 900, DateTimeOffset.UnixEpoch)
|
|
{
|
|
Kind = AlarmKind.NativeOpcUa,
|
|
AckTime = ackedAt
|
|
};
|
|
|
|
Assert.Equal(ackedAt, m.AckTime);
|
|
// `with` (used by the mirror to synthesise a return-to-normal) preserves it.
|
|
Assert.Equal(ackedAt, (m with { State = AlarmState.Normal }).AckTime);
|
|
}
|
|
}
|