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
@@ -17,7 +17,7 @@ using ZB.MOM.WW.ScadaBridge.TestSupport;
namespace ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests.Actors;
/// <summary>
/// Task 15: NativeAlarmActor mirrors a source's native alarms — subscribe on start,
/// NativeAlarmActor mirrors a source's native alarms — subscribe on start,
/// emit enriched AlarmStateChanged, snapshot atomic swap, retention, persistence.
/// </summary>
public class NativeAlarmActorTests : TestKit, IDisposable
@@ -26,6 +26,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
private readonly SiteStorageService _storage;
private readonly SiteRuntimeOptions _options = new();
/// <summary>Initializes the test class and its test doubles.</summary>
public NativeAlarmActorTests()
{
// SiteStorageService takes an ILocalDb now; LocalDb has no in-memory mode, so the
@@ -56,6 +57,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Source(), "inst", instanceActor, dclManager, _storage, options,
NullLogger<NativeAlarmActor>.Instance, AlarmKind.NativeOpcUa, serviceProvider)));
/// <summary>Verifies that stopping the actor releases the alarm subscription with the owner identity.</summary>
[Fact]
public void Stop_ReleasesAlarmSubscriptionWithOwnerIdentity()
{
@@ -68,6 +70,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Assert.Equal(actor, dcl.LastSender);
}
/// <summary>Verifies that a duplicate snapshot end does not clear a committed alarm.</summary>
[Fact]
public void DuplicateSnapshotEnd_DoesNotClearCommittedAlarm()
{
@@ -99,6 +102,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
instance.ExpectNoMsg(TimeSpan.FromMilliseconds(200));
}
/// <summary>Verifies that the actor sends a subscribe request for the source binding on start.</summary>
[Fact]
public void SubscribeOnStart_SendsRequestForSourceBinding()
{
@@ -111,6 +115,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Assert.Equal("ns=2;s=T01", req.SourceReference);
}
/// <summary>Verifies that a raise emits an enriched AlarmStateChanged.</summary>
[Fact]
public void Raise_EmitsEnrichedAlarmStateChanged()
{
@@ -130,10 +135,11 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Assert.Equal(800, emitted.Condition.Severity);
}
/// <summary>Verifies that a raise stamps the native source canonical name from the configured binding.</summary>
[Fact]
public void Raise_StampsNativeSourceCanonicalName_FromConfiguredBinding()
{
// DV-1: every emitted condition carries the canonical name of the source
// Every emitted condition carries the canonical name of the source
// BINDING it belongs to, so the DebugView can nest live native conditions
// under their configured binding node. It must equal the binding's
// CanonicalName used to construct the actor (Source().CanonicalName).
@@ -151,6 +157,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Assert.Equal("Pressure", emitted.NativeSourceCanonicalName);
}
/// <summary>Verifies that a snapshot completing with a missing prior alarm emits a return to normal.</summary>
[Fact]
public void SnapshotComplete_WithMissingPriorAlarm_EmitsReturnToNormal()
{
@@ -174,6 +181,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Assert.Equal(AlarmState.Normal, cleared.State);
}
/// <summary>Verifies that an older transition is ignored.</summary>
[Fact]
public void OlderTransition_IsIgnored()
{
@@ -196,7 +204,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
instance.ExpectNoMsg(TimeSpan.FromMilliseconds(300));
}
// ── PLAN-03 Task 20 (P4): coalesced batched persistence ─────────────────
// ── Coalesced batched persistence ─────────────────
private IActorRef SpawnWithFlush(IActorRef instanceActor, IActorRef dclManager, TimeSpan flushInterval) =>
ActorOf(Props.Create(() => new NativeAlarmActor(
@@ -208,6 +216,8 @@ public class NativeAlarmActorTests : TestKit, IDisposable
sourceRef, AlarmTransitionKind.Raise,
new AlarmConditionState(true, false, null, AlarmShelveState.Unshelved, false, severity), time)));
/// <summary>Verifies that an alarm storm coalesces persistence so the latest write per source reference wins.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task AlarmStorm_CoalescesPersistence_LatestPerSourceRefWins()
{
@@ -226,12 +236,14 @@ public class NativeAlarmActorTests : TestKit, IDisposable
var rows = await _storage.GetNativeAlarmsAsync("inst", Source().CanonicalName);
Assert.Equal(5, rows.Count);
// The LAST write for ref-4 carries severity 49 (i = 49, 49 % 5 == 4).
// The LAST write for source ref 4 carries severity 49 (i = 49, 49 % 5 == 4).
Assert.Contains(rows, r => r.ConditionJson.Contains("49"));
}
// ── PLAN-03 Task 21 (UA4): rehydration restores display metadata ────────
// ── Rehydration restores display metadata ────────
/// <summary>Verifies that rehydration restores the display metadata.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Rehydration_RestoresDisplayMetadata()
{
@@ -266,8 +278,9 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Assert.Equal("Tank overflow", emitted.Message);
}
// ── M1.5: site event log `alarm` category ──────────────────────────────
// ── Site event log `alarm` category ──────────────────────────────
/// <summary>Verifies that a raise emits an alarm site event.</summary>
[Fact]
public void Raise_EmitsAlarmSiteEvent()
{
@@ -293,6 +306,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
}, TimeSpan.FromSeconds(2));
}
/// <summary>Verifies that a clear emits an informational alarm site event.</summary>
[Fact]
public void Clear_EmitsInfoAlarmSiteEvent()
{
@@ -323,6 +337,8 @@ public class NativeAlarmActorTests : TestKit, IDisposable
}, TimeSpan.FromSeconds(2));
}
/// <summary>Verifies that rehydration does not emit a site event.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Rehydration_DoesNotEmitSiteEvent()
{
@@ -352,6 +368,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
TimeSpan.FromSeconds(1));
}
/// <summary>Verifies that a snapshot swap with an existing active condition does not re-emit.</summary>
[Fact]
public void SnapshotSwap_ExistingActiveCondition_DoesNotReEmit()
{
@@ -386,6 +403,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Assert.Single(siteLog.OfType("alarm"));
}
/// <summary>Verifies that an acknowledge emits an informational alarm site event mentioning acknowledged.</summary>
[Fact]
public void Acknowledge_EmitsInfoAlarmSiteEventMentioningAcknowledged()
{
@@ -418,17 +436,18 @@ public class NativeAlarmActorTests : TestKit, IDisposable
}, TimeSpan.FromSeconds(2));
}
// ── SiteRuntime-028: cap eviction emits a return-to-normal for an active drop ──
// ── Cap eviction emits a return-to-normal for an active drop ──
/// <summary>Verifies that enforcing the cap evicts the oldest active condition and emits a return to normal and a drop signal.</summary>
[Fact]
public void EnforceCap_EvictsActiveOldestCondition_EmitsReturnToNormalAndDropSignal()
{
// SiteRuntime-028: a cap eviction that drops a still-Active condition without a
// A cap eviction that drops a still-Active condition without a
// return-to-normal leaves the Instance Actor (and central's stream / the
// operator Alarm Summary) showing a phantom Active alarm forever. With cap=1,
// raising a second condition evicts the oldest (still Active) one — which must
// produce a Normal AlarmStateChanged for the evicted SourceReference, plus the
// SiteRuntime-027 NativeAlarmDropped so the parent evicts its stale key.
// NativeAlarmDropped so the parent evicts its stale key.
var instance = CreateTestProbe();
var dcl = CreateTestProbe();
var options = new SiteRuntimeOptions { MirroredAlarmCapPerSource = 1 };
@@ -456,12 +475,13 @@ public class NativeAlarmActorTests : TestKit, IDisposable
instance.ExpectMsg<NativeAlarmDropped>(m => m.SourceReference == "OLD.Hi");
}
// ── SiteRuntime-027: terminal retention drop signals the parent to evict its key ──
// ── Terminal retention drop signals the parent to evict its key ──
/// <summary>Verifies that a retention drop of a resolved condition emits a return to normal and then a drop signal.</summary>
[Fact]
public void RetentionDrop_ResolvedCondition_EmitsReturnToNormalThenDropSignal()
{
// SiteRuntime-027: when a native condition resolves (inactive AND acknowledged)
// When a native condition resolves (inactive AND acknowledged)
// it drops out of the mirror. The Instance Actor must be told (NativeAlarmDropped)
// so its _latestAlarmEvents map does not retain a stale (Normal) entry forever —
// otherwise a source that mints a fresh SourceReference per occurrence leaks one
@@ -486,6 +506,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
instance.ExpectMsg<NativeAlarmDropped>(m => m.SourceReference == "T01.Hi");
}
/// <inheritdoc />
void IDisposable.Dispose()
{
// Shut the actor system down FIRST: in-flight alarm actors still hold the
@@ -500,6 +521,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
// ── MES alarm-status API §6.4: AckTime through the mirror ──────────────
/// <summary>Verifies that the emitted state carries the adapter's ack time verbatim.</summary>
[Fact]
public void Emit_CarriesTheAdaptersAckTimeVerbatim()
{
@@ -527,6 +549,8 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Assert.True(acked.Condition.Acknowledged);
}
/// <summary>Verifies that rehydration restores the ack time so it survives failover.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Rehydration_RestoresAckTime_SoItSurvivesFailover()
{
@@ -561,6 +585,8 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Assert.Equal(ackedAt, emitted.AckTime);
}
/// <summary>Verifies that rehydrating a row from before ack times existed leaves the ack time null.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Rehydration_OfAPreAckTimeRow_LeavesAckTimeNull()
{
@@ -591,6 +617,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Assert.Null(emitted.AckTime); // …with no ack time invented
}
/// <summary>Verifies that a lost subscribe response causes the subscribe to be resent.</summary>
[Fact]
public void LostSubscribeResponse_ResendsSubscribe()
{
@@ -604,6 +631,9 @@ public class NativeAlarmActorTests : TestKit, IDisposable
// Swallow the response entirely — the actor must still re-subscribe.
dcl.ExpectMsg<SubscribeAlarmsRequest>(TimeSpan.FromSeconds(5));
}
/// <summary>Verifies that a late rehydration cannot resurrect a resolved or snapshot-removed alarm.</summary>
/// <param name="snapshot">Whether the scenario removes the alarm through a snapshot rather than resolving it.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
[Theory]
[InlineData(false)]
[InlineData(true)]
@@ -627,6 +657,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
Assert.DoesNotContain(messages.OfType<AlarmStateChanged>(), e => e.State == AlarmState.Active);
}
/// <summary>Verifies that a stale success cannot cancel the current subscribe retry.</summary>
[Fact]
public void SR3_StaleSuccessCannotCancelCurrentSubscribeRetry()
{
@@ -641,6 +672,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
dcl.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
}
/// <summary>Verifies that a connection-wide restart discards an interrupted MX snapshot.</summary>
[Fact]
public void DC5_ConnectionWideRestartDiscardsInterruptedMxSnapshot()
{
@@ -654,6 +686,7 @@ public class NativeAlarmActorTests : TestKit, IDisposable
parent.ExpectNoMsg(TimeSpan.FromMilliseconds(200));
}
/// <summary>Verifies that a live clear during a snapshot cannot be resurrected by the snapshot end.</summary>
[Fact]
public void DC5_LiveClearDuringSnapshotCannotBeResurrectedBySnapshotEnd()
{