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
@@ -5,7 +5,7 @@ using ZB.MOM.WW.ScadaBridge.Commons.Messages.Health;
namespace ZB.MOM.WW.ScadaBridge.HealthMonitoring.Tests;
/// <summary>
/// HealthMonitoring-009 regression: the central self-report loop had no test
/// Regression tests for the central self-report loop, which had no test
/// coverage at all. These tests exercise leader-only gating (SelfIsPrimary),
/// self-report generation for siteId="central", and monotonic sequence
/// assignment.
@@ -14,24 +14,33 @@ public class CentralHealthReportLoopTests
{
private sealed class FakeClusterNodeProvider : IClusterNodeProvider
{
/// <inheritdoc />
public bool SelfIsPrimary { get; set; }
/// <summary>Gets or sets the nodes returned by <c>GetClusterNodes</c>.</summary>
public IReadOnlyList<NodeStatus> Nodes { get; set; } = [];
/// <inheritdoc />
public IReadOnlyList<NodeStatus> GetClusterNodes() => Nodes;
}
private sealed class RecordingAggregator : ICentralHealthAggregator
{
/// <summary>Gets the reports passed to <see cref="ProcessReport"/>.</summary>
public List<SiteHealthReport> Processed { get; } = [];
/// <inheritdoc />
public void ProcessReport(SiteHealthReport report) => Processed.Add(report);
/// <inheritdoc />
public void MarkHeartbeat(string siteId, DateTimeOffset receivedAt) { }
/// <inheritdoc />
public IReadOnlyDictionary<string, SiteHealthState> GetAllSiteStates() =>
new Dictionary<string, SiteHealthState>();
/// <inheritdoc />
public SiteHealthState? GetSiteState(string siteId) => null;
/// <inheritdoc />
public void PruneUnknownSites(IReadOnlyCollection<string> knownSiteIds) { }
}
/// <summary>
/// HealthMonitoring-022 de-flake: <see cref="CentralHealthReportLoop"/>'s
/// De-flake note: <see cref="CentralHealthReportLoop"/>'s
/// internal cadence is a real <see cref="PeriodicTimer"/>, so the loop is
/// timing-sensitive. We can't drive a virtual clock (PeriodicTimer doesn't
/// consume <see cref="TimeProvider"/>) without refactoring the production
@@ -82,6 +91,8 @@ public class CentralHealthReportLoopTests
catch (OperationCanceledException) { }
}
/// <summary>Verifies that the loop generates central reports when this node is the primary.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task GeneratesCentralReports_WhenSelfIsPrimary()
{
@@ -97,7 +108,7 @@ public class CentralHealthReportLoopTests
collector, aggregator, clusterNodes, options,
NullLogger<CentralHealthReportLoop>.Instance);
// HealthMonitoring-022: wait up to 5 s for at least one report to fire
// Wait up to 5 s for at least one report to fire
// rather than fixed-budget Task.Delay; tolerates slow CI runners.
await RunLoopUntil(loop, () => aggregator.Processed.Count >= 1);
@@ -106,6 +117,8 @@ public class CentralHealthReportLoopTests
r => Assert.Equal(CentralHealthReportLoop.CentralSiteId, r.SiteId));
}
/// <summary>Verifies that the loop generates no reports when this node is not the primary.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task GeneratesNoReports_WhenNotPrimary()
{
@@ -126,6 +139,8 @@ public class CentralHealthReportLoopTests
Assert.Empty(aggregator.Processed);
}
/// <summary>Verifies that the loop assigns monotonically increasing sequence numbers.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task AssignsMonotonicSequenceNumbers()
{
@@ -141,7 +156,7 @@ public class CentralHealthReportLoopTests
collector, aggregator, clusterNodes, options,
NullLogger<CentralHealthReportLoop>.Instance);
// HealthMonitoring-022: wait up to 5 s for at least 2 reports rather
// Wait up to 5 s for at least 2 reports rather
// than a fixed 300 ms window that could miss the second tick on a
// slow CI runner; the assertion below proves the sequence is monotonic.
await RunLoopUntil(loop, () => aggregator.Processed.Count >= 2);
@@ -157,7 +172,7 @@ public class CentralHealthReportLoopTests
}
/// <summary>
/// HealthMonitoring-006 regression: the central loop's sequence-number seed
/// Regression: the central loop's sequence-number seed
/// must be derived from the injected <see cref="TimeProvider"/> (Unix-ms),
/// not from <c>DateTimeOffset.UtcNow</c> read at field initialization, so the
/// seeding strategy is deterministically testable.
@@ -180,13 +195,14 @@ public class CentralHealthReportLoopTests
}
/// <summary>
/// HealthMonitoring-018 regression: when <see cref="ICentralHealthAggregator.ProcessReport"/>
/// Regression: when <see cref="ICentralHealthAggregator.ProcessReport"/>
/// throws, the per-interval counters that
/// <see cref="SiteHealthCollector.CollectReport"/> just drained must be
/// restored back into the shared collector so they roll forward into the
/// next interval rather than being silently lost. Same shape as the
/// HealthMonitoring-017 fix in <see cref="HealthReportSender"/>.
/// restore-on-failure fix in <see cref="HealthReportSender"/>.
/// </summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ProcessReportFailure_PreservesIntervalCountersForNextReport()
{
@@ -216,7 +232,7 @@ public class CentralHealthReportLoopTests
collector, aggregator, clusterNodes, options,
NullLogger<CentralHealthReportLoop>.Instance);
// HealthMonitoring-022: the first ProcessReport call throws (counters
// The first ProcessReport call throws (counters
// get restored), the second succeeds. Wait up to 5 s for that second
// (successful) call rather than a fixed 450 ms budget.
await RunLoopUntil(loop, () => aggregator.Processed.Count >= 1);
@@ -236,13 +252,15 @@ public class CentralHealthReportLoopTests
/// <see cref="ICentralHealthAggregator"/> whose first <c>ProcessReport</c>
/// call throws (only the first), then subsequent calls succeed. Used by
/// <see cref="ProcessReportFailure_PreservesIntervalCountersForNextReport"/>
/// to verify the HealthMonitoring-018 restore-on-failure path.
/// to verify the restore-on-failure path.
/// </summary>
private sealed class FailingThenSucceedingAggregator : ICentralHealthAggregator
{
private int _callCount;
/// <summary>Gets the reports that were processed successfully.</summary>
public List<SiteHealthReport> Processed { get; } = [];
/// <inheritdoc />
public void ProcessReport(SiteHealthReport report)
{
var n = Interlocked.Increment(ref _callCount);
@@ -253,13 +271,19 @@ public class CentralHealthReportLoopTests
Processed.Add(report);
}
/// <inheritdoc />
public void MarkHeartbeat(string siteId, DateTimeOffset receivedAt) { }
/// <inheritdoc />
public IReadOnlyDictionary<string, SiteHealthState> GetAllSiteStates() =>
new Dictionary<string, SiteHealthState>();
/// <inheritdoc />
public SiteHealthState? GetSiteState(string siteId) => null;
/// <inheritdoc />
public void PruneUnknownSites(IReadOnlyCollection<string> knownSiteIds) { }
}
/// <summary>Verifies that the active-node flag is set on the report even when this node is not the primary.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task SetsActiveNodeFlag_EvenWhenNotPrimary()
{