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.
This commit is contained in:
Joseph Doherty
2026-10-07 15:05:49 -04:00
parent 0ffd4bdbea
commit 513fa1aa16
998 changed files with 17896 additions and 2395 deletions
@@ -14,8 +14,8 @@ using ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests.TestSupport;
namespace ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests.Actors;
/// <summary>
/// WP-16: Alarm Actor tests — value match, range violation, rate of change.
/// WP-21: Alarm on-trigger call direction tests.
/// Alarm Actor tests — value match, range violation, rate of change.
/// Alarm on-trigger call direction tests.
/// </summary>
public class AlarmActorTests : TestKit, IDisposable
{
@@ -23,6 +23,7 @@ public class AlarmActorTests : TestKit, IDisposable
private readonly SiteRuntimeOptions _options;
private readonly ScriptCompilationService _compilationService;
/// <summary>Initializes the test with a compilation service, shared script library and default runtime options.</summary>
public AlarmActorTests()
{
_compilationService = new ScriptCompilationService(
@@ -32,11 +33,13 @@ public class AlarmActorTests : TestKit, IDisposable
_options = new SiteRuntimeOptions();
}
/// <inheritdoc />
void IDisposable.Dispose()
{
Shutdown();
}
/// <summary>Verifies that a value-match alarm activates when the value matches.</summary>
[Fact]
public void AlarmActor_ValueMatch_ActivatesOnMatch()
{
@@ -64,6 +67,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal("HighTemp", msg.AlarmName);
}
/// <summary>Verifies that a value-match alarm clears when the value no longer matches.</summary>
[Fact]
public void AlarmActor_ValueMatch_ClearsOnNonMatch()
{
@@ -94,6 +98,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmState.Normal, clearMsg.State);
}
/// <summary>Verifies that a computed alarm carries the unified condition state.</summary>
[Fact]
public void AlarmActor_ComputedAlarm_CarriesUnifiedConditionState()
{
@@ -123,6 +128,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(string.Empty, msg.SourceReference); // no native source reference
}
/// <summary>Verifies that a range-violation alarm activates when the value is outside the range.</summary>
[Fact]
public void AlarmActor_RangeViolation_ActivatesOutsideRange()
{
@@ -152,6 +158,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmState.Active, msg.State);
}
/// <summary>Verifies that a range-violation alarm clears when the value is back in range.</summary>
[Fact]
public void AlarmActor_RangeViolation_ClearsWhenBackInRange()
{
@@ -181,6 +188,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmState.Normal, clearMsg.State);
}
/// <summary>Verifies that the alarm actor ignores changes to attributes it does not monitor.</summary>
[Fact]
public void AlarmActor_IgnoresUnmonitoredAttributes()
{
@@ -205,6 +213,7 @@ public class AlarmActorTests : TestKit, IDisposable
instanceProbe.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
}
/// <summary>Verifies that an alarm that is already active does not trigger again.</summary>
[Fact]
public void AlarmActor_DoesNotReTrigger_WhenAlreadyActive()
{
@@ -233,6 +242,7 @@ public class AlarmActorTests : TestKit, IDisposable
instanceProbe.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
}
/// <summary>Verifies that the alarm actor starts in the normal state after a restart.</summary>
[Fact]
public void AlarmActor_StartsNormal_OnRestart()
{
@@ -257,10 +267,11 @@ public class AlarmActorTests : TestKit, IDisposable
instanceProbe.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
}
/// <summary>Verifies that no on-clear script runs when the alarm deactivates.</summary>
[Fact]
public void AlarmActor_NoClearScript_OnDeactivation()
{
// WP-16: On clear, NO script is executed. Only on activate.
// On clear, NO script is executed. Only on activate.
var alarmConfig = new ResolvedAlarm
{
CanonicalName = "ClearTest",
@@ -320,6 +331,7 @@ public class AlarmActorTests : TestKit, IDisposable
value.ToString(System.Globalization.CultureInfo.InvariantCulture),
"Good", ts);
/// <summary>Verifies that an either-direction rate-of-change alarm activates on a rapid rise.</summary>
[Fact]
public void AlarmActor_RateOfChange_Either_ActivatesOnRapidRise()
{
@@ -339,6 +351,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmState.Active, msg.State);
}
/// <summary>Verifies that an either-direction rate-of-change alarm activates on a rapid fall.</summary>
[Fact]
public void AlarmActor_RateOfChange_Either_ActivatesOnRapidFall()
{
@@ -356,6 +369,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmState.Active, msg.State);
}
/// <summary>Verifies that an either-direction rate-of-change alarm does not activate when the rate is below the threshold.</summary>
[Fact]
public void AlarmActor_RateOfChange_Either_DoesNotActivateWhenBelowThreshold()
{
@@ -370,6 +384,7 @@ public class AlarmActorTests : TestKit, IDisposable
instanceProbe.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
}
/// <summary>Verifies that a rising rate-of-change alarm ignores falling spikes.</summary>
[Fact]
public void AlarmActor_RateOfChange_Rising_IgnoresFallingSpikes()
{
@@ -384,6 +399,7 @@ public class AlarmActorTests : TestKit, IDisposable
instanceProbe.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
}
/// <summary>Verifies that a falling rate-of-change alarm ignores rising spikes.</summary>
[Fact]
public void AlarmActor_RateOfChange_Falling_IgnoresRisingSpikes()
{
@@ -397,6 +413,7 @@ public class AlarmActorTests : TestKit, IDisposable
instanceProbe.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
}
/// <summary>Verifies that a falling rate-of-change alarm activates on a falling rate.</summary>
[Fact]
public void AlarmActor_RateOfChange_Falling_ActivatesOnFallingRate()
{
@@ -411,6 +428,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmState.Active, msg.State);
}
/// <summary>Verifies that a rate-of-change alarm does not activate on a single sample.</summary>
[Fact]
public void AlarmActor_RateOfChange_SingleSample_DoesNotActivate()
{
@@ -424,6 +442,7 @@ public class AlarmActorTests : TestKit, IDisposable
instanceProbe.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
}
/// <summary>Verifies that rate-of-change samples that roll out of the window are discarded.</summary>
[Fact]
public void AlarmActor_RateOfChange_WindowRollsOff_OldSamplesDiscarded()
{
@@ -442,6 +461,7 @@ public class AlarmActorTests : TestKit, IDisposable
instanceProbe.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
}
/// <summary>Verifies that a rate-of-change alarm clears when the rate drops back.</summary>
[Fact]
public void AlarmActor_RateOfChange_ClearsWhenRateDropsBack()
{
@@ -465,6 +485,7 @@ public class AlarmActorTests : TestKit, IDisposable
// ── Legacy JSON aliases & not-equals prefix ────────────────────────────
/// <summary>Verifies that a value-match alarm using the legacy attribute and value keys still fires.</summary>
[Fact]
public void AlarmActor_ValueMatch_LegacyAttributeAndValueKeys_StillFire()
{
@@ -490,6 +511,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmState.Active, msg.State);
}
/// <summary>Verifies that a value-match alarm with a not-equals prefix fires when the value differs.</summary>
[Fact]
public void AlarmActor_ValueMatch_NotEqualsPrefix_FiresWhenValueDiffers()
{
@@ -521,6 +543,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmState.Normal, clear.State);
}
/// <summary>Verifies that a range-violation alarm using the legacy low and high keys still fires.</summary>
[Fact]
public void AlarmActor_RangeViolation_LegacyLowHighKeys_StillFire()
{
@@ -574,6 +597,7 @@ public class AlarmActorTests : TestKit, IDisposable
value.ToString(System.Globalization.CultureInfo.InvariantCulture),
"Good", DateTimeOffset.UtcNow);
/// <summary>Verifies that a HiLo alarm enters the High level when the value crosses the Hi setpoint.</summary>
[Fact]
public void AlarmActor_HiLo_EntersHigh_WhenValueCrossesHi()
{
@@ -591,6 +615,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.High, msg.Level);
}
/// <summary>Verifies that a HiLo alarm escalates to HighHigh when the value climbs past the HiHi setpoint.</summary>
[Fact]
public void AlarmActor_HiLo_EscalatesToHighHigh_WhenValueClimbsPastHiHi()
{
@@ -609,6 +634,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.HighHigh, second.Level);
}
/// <summary>Verifies that a HiLo alarm descalates from HighHigh to High when the value drops.</summary>
[Fact]
public void AlarmActor_HiLo_DescalatesFromHighHighToHigh_WhenValueDrops()
{
@@ -626,6 +652,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.High, msg.Level);
}
/// <summary>Verifies that a HiLo alarm clears to Normal when the value returns to the normal band.</summary>
[Fact]
public void AlarmActor_HiLo_ClearsToNormal_WhenValueReturnsToNormalBand()
{
@@ -643,6 +670,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.None, clear.Level);
}
/// <summary>Verifies that a HiLo alarm enters Low when the value crosses the Lo setpoint.</summary>
[Fact]
public void AlarmActor_HiLo_EntersLow_WhenValueCrossesLo()
{
@@ -656,6 +684,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.Low, msg.Level);
}
/// <summary>Verifies that a HiLo alarm enters LowLow when the value crosses the LoLo setpoint.</summary>
[Fact]
public void AlarmActor_HiLo_EntersLowLow_WhenValueCrossesLoLo()
{
@@ -669,6 +698,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.LowLow, msg.Level);
}
/// <summary>Verifies that a per-setpoint priority overrides the alarm-level priority.</summary>
[Fact]
public void AlarmActor_HiLo_PerSetpointPriority_OverridesAlarmLevelPriority()
{
@@ -688,6 +718,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(900, hiHi.Priority);
}
/// <summary>Verifies that a setpoint without its own priority falls back to the alarm-level priority.</summary>
[Fact]
public void AlarmActor_HiLo_MissingPerSetpointPriority_FallsBackToAlarmLevel()
{
@@ -701,6 +732,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(432, msg.Priority);
}
/// <summary>Verifies that with only HiHi configured a HiLo alarm has no effect in the low range.</summary>
[Fact]
public void AlarmActor_HiLo_PartialConfig_OnlyHiHiSet_NoEffectInLowRange()
{
@@ -720,6 +752,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.HighHigh, msg.Level);
}
/// <summary>Verifies that a value exactly at the HiHi setpoint resolves to HighHigh.</summary>
[Fact]
public void AlarmActor_HiLo_BoundaryValue_AtHiHi_ResolvesToHighHigh()
{
@@ -735,6 +768,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.HighHigh, msg.Level);
}
/// <summary>Verifies that a HiLo alarm that stays at the same level emits no redundant state change.</summary>
[Fact]
public void AlarmActor_HiLo_StaysAtSameLevel_NoRedundantEmission()
{
@@ -752,6 +786,7 @@ public class AlarmActorTests : TestKit, IDisposable
instanceProbe.ExpectNoMsg(TimeSpan.FromMilliseconds(400));
}
/// <summary>Verifies that a HiLo alarm with no setpoints configured never fires.</summary>
[Fact]
public void AlarmActor_HiLo_NoSetpointsConfigured_NeverFires()
{
@@ -769,6 +804,7 @@ public class AlarmActorTests : TestKit, IDisposable
// ── HiLo hysteresis ────────────────────────────────────────────────────
/// <summary>Verifies that with hysteresis a HiLo alarm stays at HighHigh until the value drops below the deadband.</summary>
[Fact]
public void AlarmActor_HiLo_Hysteresis_StaysAtHighHigh_UntilDropsBelowDeadband()
{
@@ -787,6 +823,7 @@ public class AlarmActorTests : TestKit, IDisposable
instanceProbe.ExpectNoMsg(TimeSpan.FromMilliseconds(300));
}
/// <summary>Verifies that with hysteresis a HiLo alarm drops to High only after the deadband is cleared.</summary>
[Fact]
public void AlarmActor_HiLo_Hysteresis_DropsToHigh_OnlyAfterDeadbandCleared()
{
@@ -803,6 +840,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.High, msg.Level);
}
/// <summary>Verifies that the Hi deadband prevents a HiLo alarm from flapping.</summary>
[Fact]
public void AlarmActor_HiLo_Hysteresis_HiDeadband_PreventsFlapping()
{
@@ -822,6 +860,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.None, clear.Level);
}
/// <summary>Verifies that hysteresis on the low side behaves symmetrically to the high side.</summary>
[Fact]
public void AlarmActor_HiLo_Hysteresis_LowSide_Symmetric()
{
@@ -842,6 +881,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.None, clear.Level);
}
/// <summary>Verifies that a per-band message flows through to the alarm state change.</summary>
[Fact]
public void AlarmActor_HiLo_PerBandMessage_FlowsToAlarmStateChanged()
{
@@ -863,6 +903,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(string.Empty, clear.Message);
}
/// <summary>Verifies that hysteresis does not delay escalation to a higher level.</summary>
[Fact]
public void AlarmActor_HiLo_Hysteresis_DoesNotDelayEscalation()
{
@@ -880,8 +921,9 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmLevel.HighHigh, escalated.Level);
}
// ── M1.5: site event log `alarm` category ──────────────────────────────
// ── Site event log `alarm` category ──────────────────────────────
/// <summary>Verifies that raising an alarm emits an alarm site event.</summary>
[Fact]
public void AlarmActor_Raise_EmitsAlarmSiteEvent()
{
@@ -918,6 +960,7 @@ public class AlarmActorTests : TestKit, IDisposable
}, TimeSpan.FromSeconds(2));
}
/// <summary>Verifies that raising a low-priority alarm emits a warning-severity alarm site event.</summary>
[Fact]
public void AlarmActor_RaiseLowPriority_EmitsWarningAlarmSiteEvent()
{
@@ -950,6 +993,7 @@ public class AlarmActorTests : TestKit, IDisposable
}, TimeSpan.FromSeconds(2));
}
/// <summary>Verifies that clearing an alarm emits an info-severity alarm site event.</summary>
[Fact]
public void AlarmActor_Clear_EmitsInfoAlarmSiteEvent()
{
@@ -986,6 +1030,7 @@ public class AlarmActorTests : TestKit, IDisposable
}, TimeSpan.FromSeconds(2));
}
/// <summary>Verifies that a malformed trigger configuration does not crash the alarm actor.</summary>
[Fact]
public void AlarmActor_MalformedTriggerConfig_DoesNotCrash()
{
@@ -1027,13 +1072,14 @@ public class AlarmActorTests : TestKit, IDisposable
return s;
}
/// <summary>Verifies that an expression alarm evaluates off the blocking script pool and activates.</summary>
[Fact]
public void ExpressionAlarm_EvaluatesOffTheBlockingScriptPool_AndActivates()
{
// WP3.1 retarget of the former P1 assertion, whose sense is deliberately INVERTED.
// Retarget of the former assertion, whose sense is deliberately INVERTED.
//
// P1 moved the evaluation off the actor's dispatcher and onto the dedicated
// script-execution scheduler, and this test asserted exactly that. WP3.1 (finding #4)
// An earlier change moved the evaluation off the actor's dispatcher and onto the dedicated
// script-execution scheduler, and this test asserted exactly that. Later analysis
// proved that destination wrong for alarms in particular: sharing the blocking pool
// meant an alarm that should raise in milliseconds queued behind blocked script bodies
// for an unbounded time, and its 2 s evaluation timeout did not even start ticking
@@ -1063,6 +1109,7 @@ public class AlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmState.Active, change.State);
}
/// <summary>Verifies that a fault in the expression evaluation task does not kill the alarm trigger.</summary>
[Fact]
public void ExpressionEvalTaskFault_DoesNotKillTheAlarmTrigger()
{