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
@@ -12,13 +12,18 @@ internal sealed class TestTimeProvider : TimeProvider
{
private DateTimeOffset _utcNow;
/// <summary>Initializes the provider at the given start time.</summary>
/// <param name="startTime">The initial UTC time reported by the provider.</param>
public TestTimeProvider(DateTimeOffset startTime)
{
_utcNow = startTime;
}
/// <inheritdoc />
public override DateTimeOffset GetUtcNow() => _utcNow;
/// <summary>Advances the fake clock by the given duration.</summary>
/// <param name="duration">The amount of time to advance.</param>
public void Advance(TimeSpan duration) => _utcNow += duration;
}
@@ -27,6 +32,7 @@ public class CentralHealthAggregatorTests
private readonly TestTimeProvider _timeProvider;
private readonly CentralHealthAggregator _aggregator;
/// <summary>Initializes the tests with a controllable clock and a fresh aggregator.</summary>
public CentralHealthAggregatorTests()
{
_timeProvider = new TestTimeProvider(DateTimeOffset.UtcNow);
@@ -72,6 +78,7 @@ public class CentralHealthAggregatorTests
EnabledInstanceCount: 0,
DisabledInstanceCount: 0);
/// <summary>Verifies that processing a report stores the state for a new site.</summary>
[Fact]
public void ProcessReport_StoresState_ForNewSite()
{
@@ -83,6 +90,7 @@ public class CentralHealthAggregatorTests
Assert.Equal(1, state.LastSequenceNumber);
}
/// <summary>Verifies that processing a report updates the state when the sequence number increases.</summary>
[Fact]
public void ProcessReport_UpdatesState_WhenSequenceIncreases()
{
@@ -93,6 +101,7 @@ public class CentralHealthAggregatorTests
Assert.Equal(2, state!.LastSequenceNumber);
}
/// <summary>Verifies that a report whose sequence number is not greater than the stored one is rejected as stale.</summary>
[Fact]
public void ProcessReport_RejectsStaleReport_WhenSequenceNotGreater()
{
@@ -103,6 +112,7 @@ public class CentralHealthAggregatorTests
Assert.Equal(5, state!.LastSequenceNumber);
}
/// <summary>Verifies that a report with a sequence number equal to the stored one is rejected.</summary>
[Fact]
public void ProcessReport_RejectsEqualSequence()
{
@@ -113,6 +123,7 @@ public class CentralHealthAggregatorTests
Assert.Equal(5, state!.LastSequenceNumber);
}
/// <summary>Verifies that a site goes offline when no report arrives within the timeout.</summary>
[Fact]
public void OfflineDetection_SiteGoesOffline_WhenNoReportWithinTimeout()
{
@@ -126,6 +137,7 @@ public class CentralHealthAggregatorTests
Assert.False(_aggregator.GetSiteState("site-1")!.IsOnline);
}
/// <summary>Verifies that an offline site comes back online when a report is received.</summary>
[Fact]
public void OnlineRecovery_SiteComesBackOnline_WhenReportReceived()
{
@@ -141,6 +153,7 @@ public class CentralHealthAggregatorTests
Assert.True(_aggregator.GetSiteState("site-1")!.IsOnline);
}
/// <summary>Verifies that a site remains online when a report arrives within the timeout.</summary>
[Fact]
public void OfflineDetection_SiteRemainsOnline_WhenReportWithinTimeout()
{
@@ -152,6 +165,7 @@ public class CentralHealthAggregatorTests
Assert.True(_aggregator.GetSiteState("site-1")!.IsOnline);
}
/// <summary>Verifies that all known sites are returned by the all-states query.</summary>
[Fact]
public void GetAllSiteStates_ReturnsAllKnownSites()
{
@@ -164,6 +178,7 @@ public class CentralHealthAggregatorTests
Assert.Contains("site-2", states.Keys);
}
/// <summary>Verifies that the state lookup returns null for an unknown site.</summary>
[Fact]
public void GetSiteState_ReturnsNull_ForUnknownSite()
{
@@ -171,6 +186,7 @@ public class CentralHealthAggregatorTests
Assert.Null(state);
}
/// <summary>Verifies that processing a report stores the latest report for the site.</summary>
[Fact]
public void ProcessReport_StoresLatestReport()
{
@@ -182,13 +198,14 @@ public class CentralHealthAggregatorTests
}
/// <summary>
/// HealthMonitoring-002 regression: SiteHealthState is mutated from multiple
/// Regression test: SiteHealthState is mutated from multiple
/// threads (ProcessReport, MarkHeartbeat, CheckForOfflineSites). With a mutable
/// class and unsynchronized field writes, a snapshot read could observe a torn
/// or half-applied state. The state must be immutable and every transition an
/// atomic reference swap, so a snapshot is always internally consistent and the
/// monotonic sequence-number guard is never subverted by a lost update.
/// </summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ProcessReport_ConcurrentUpdates_NeverLoseSequenceOrTearState()
{
@@ -237,7 +254,7 @@ public class CentralHealthAggregatorTests
}
/// <summary>
/// HealthMonitoring-007 regression: a heartbeat for a site that has not yet
/// Regression test: a heartbeat for a site that has not yet
/// sent a full report (e.g. immediately after a central restart/failover, when
/// the aggregator's in-memory state is empty) must register the site as online
/// rather than being silently discarded. Otherwise reachable sites show as
@@ -258,9 +275,9 @@ public class CentralHealthAggregatorTests
}
/// <summary>
/// Regression test for HealthMonitoring-015. A heartbeat-only registered site
/// Regression test: a heartbeat-only registered site
/// has never processed a full report, so <see cref="SiteHealthState.LastReportReceivedAt"/>
/// must be <c>null</c> — not the <c>DateTimeOffset.MinValue</c> (year-0001)
/// must be <c>null</c> — not the <c>DateTimeOffset.MinValue</c> (year 0001)
/// sentinel that the UI would otherwise render as a ~2000-year-stale timestamp.
/// The "no report yet" signal must be an explicit nullable state, consistent
/// with <see cref="SiteHealthState.LatestReport"/>.
@@ -276,7 +293,7 @@ public class CentralHealthAggregatorTests
}
/// <summary>
/// Regression test for HealthMonitoring-015. Once a full report is processed
/// Regression test: once a full report is processed
/// for a heartbeat-registered site, <see cref="SiteHealthState.LastReportReceivedAt"/>
/// becomes a real (non-null) instant.
/// </summary>
@@ -294,6 +311,7 @@ public class CentralHealthAggregatorTests
Assert.Equal(reportTime, state.LastReportReceivedAt);
}
/// <summary>Verifies that heartbeats keep a site online between full reports.</summary>
[Fact]
public void MarkHeartbeat_KeepsSiteOnline_BetweenReports()
{
@@ -310,6 +328,7 @@ public class CentralHealthAggregatorTests
Assert.True(_aggregator.GetSiteState("site-1")!.IsOnline);
}
/// <summary>Verifies that a heartbeat brings an offline site back online.</summary>
[Fact]
public void MarkHeartbeat_BringsOfflineSiteBackOnline()
{
@@ -324,7 +343,7 @@ public class CentralHealthAggregatorTests
}
/// <summary>
/// HealthMonitoring-020 regression: an offline-to-online transition must
/// Regression test: an offline-to-online transition must
/// be backed by a fresh LastHeartbeatAt. Previously MarkHeartbeat used
/// <c>max(receivedAt, existing.LastHeartbeatAt)</c>, so an out-of-order
/// heartbeat carrying an older timestamp would bring the site online with
@@ -357,7 +376,7 @@ public class CentralHealthAggregatorTests
}
/// <summary>
/// HealthMonitoring-005 regression: the synthetic "central" site has no
/// Regression test: the synthetic "central" site has no
/// heartbeat source — its LastHeartbeatAt is only bumped by the 30s
/// CentralHealthReportLoop self-report. A single skipped/late self-report
/// (leader GC pause, brief stall, mid-failover) would leave it with no signal
@@ -382,6 +401,7 @@ public class CentralHealthAggregatorTests
"central must survive a single missed self-report");
}
/// <summary>Verifies that the synthetic central site still goes offline on a genuine loss of self-reports.</summary>
[Fact]
public void OfflineDetection_CentralSite_StillGoesOfflineOnGenuineLoss()
{
@@ -395,7 +415,7 @@ public class CentralHealthAggregatorTests
}
/// <summary>
/// HealthMonitoring-013 regression: the offline-check cadence must be derived
/// Regression test: the offline-check cadence must be derived
/// from the *shorter* of <see cref="HealthMonitoringOptions.OfflineTimeout"/>
/// and <see cref="HealthMonitoringOptions.CentralOfflineTimeout"/>, so that if
/// an operator configures <c>CentralOfflineTimeout</c> smaller than
@@ -424,6 +444,7 @@ public class CentralHealthAggregatorTests
}));
}
/// <summary>Verifies that a sequence number reset is rejected until it exceeds the previous maximum.</summary>
[Fact]
public void SequenceNumberReset_RejectedUntilExceedsPrevMax()
{
@@ -495,7 +516,7 @@ public class CentralHealthAggregatorTests
}
/// <summary>
/// Review 01 underdeveloped #7: "when did the site drop" was unanswerable.
/// Previously "when did the site drop" was unanswerable.
/// Every online↔offline flip stamps <see cref="SiteHealthState.LastStatusChangeAt"/>.
/// </summary>
[Fact]
@@ -515,7 +536,7 @@ public class CentralHealthAggregatorTests
}
/// <summary>
/// Round-2 N3: a site known only via heartbeats (LastReportReceivedAt == null)
/// A site known only via heartbeats (LastReportReceivedAt == null)
/// previously skipped the staleness check forever — a report pipeline dead
/// from FIRST BOOT showed "online with no metrics" indefinitely. FirstSeenAt
/// anchors the window instead (LastHeartbeatAt cannot: heartbeats advance it).