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:
+24
-1
@@ -8,7 +8,7 @@ using ZB.MOM.WW.ScadaBridge.TestSupport;
|
||||
namespace ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests.Secrets;
|
||||
|
||||
/// <summary>
|
||||
/// Review finding M1: <see cref="SecretMirrorStatusReporter"/> forwards every node's
|
||||
/// <see cref="SecretMirrorStatusReporter"/> forwards every node's
|
||||
/// replicated <c>secret_mirror_status</c> row onto the site health report via the collector.
|
||||
/// </summary>
|
||||
public class SecretMirrorStatusReporterTests : IAsyncLifetime, IDisposable
|
||||
@@ -16,14 +16,19 @@ public class SecretMirrorStatusReporterTests : IAsyncLifetime, IDisposable
|
||||
private readonly TestLocalDb _localDb = TestLocalDb.CreateTemp("secret-mirror-status");
|
||||
private SiteStorageService _storage = null!;
|
||||
|
||||
/// <summary>Creates the site storage service and initializes its schema.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
public async Task InitializeAsync()
|
||||
{
|
||||
_storage = new SiteStorageService(_localDb.Db, NullLogger<SiteStorageService>.Instance);
|
||||
await _storage.InitializeAsync();
|
||||
}
|
||||
|
||||
/// <summary>Completes immediately; the synchronous <c>Dispose</c> releases the resources.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
public Task DisposeAsync() => Task.CompletedTask;
|
||||
|
||||
/// <summary>Releases the resources held by this test class.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
var path = _localDb.Path;
|
||||
@@ -31,6 +36,8 @@ public class SecretMirrorStatusReporterTests : IAsyncLifetime, IDisposable
|
||||
TestLocalDb.DeleteFiles(path);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a probe pushes every node's status row onto the next health report.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task Probe_PushesEveryNodesRow_OntoTheNextReport()
|
||||
{
|
||||
@@ -51,6 +58,7 @@ public class SecretMirrorStatusReporterTests : IAsyncLifetime, IDisposable
|
||||
Assert.Equal("OPC-PWD", Assert.Single(report.SecretMirrorStatuses[1].Failures).SecretName);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the report field is null before any probe has run.</summary>
|
||||
[Fact]
|
||||
public void BeforeAnyProbe_TheReportFieldIsNull()
|
||||
{
|
||||
@@ -59,6 +67,8 @@ public class SecretMirrorStatusReporterTests : IAsyncLifetime, IDisposable
|
||||
Assert.Null(report.SecretMirrorStatuses);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a probe with no rows yet pushes an empty list rather than null.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task Probe_NoRowsYet_PushesAnEmptyList_NotNull()
|
||||
{
|
||||
@@ -71,6 +81,8 @@ public class SecretMirrorStatusReporterTests : IAsyncLifetime, IDisposable
|
||||
Assert.Empty(collector.CollectReport("site-a").SecretMirrorStatuses!);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a read failure during a probe keeps the previous snapshot and does not throw.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task Probe_ReadFailure_KeepsThePreviousSnapshot_AndDoesNotThrow()
|
||||
{
|
||||
@@ -96,6 +108,8 @@ public class SecretMirrorStatusReporterTests : IAsyncLifetime, IDisposable
|
||||
|
||||
// ── Stale rows (decommissioned / renamed nodes) ──
|
||||
|
||||
/// <summary>Verifies that a row older than the stale-after window is left off the report and deleted.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task Probe_RowOlderThanStaleAfter_IsLeftOffTheReport_AndDeleted()
|
||||
{
|
||||
@@ -114,6 +128,8 @@ public class SecretMirrorStatusReporterTests : IAsyncLifetime, IDisposable
|
||||
Assert.Equal(["node-a"], (await _storage.GetSecretMirrorStatusesAsync()).Select(s => s.NodeName));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a row exactly at the stale cutoff is kept.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task Probe_RowExactlyAtTheCutoff_IsKept()
|
||||
{
|
||||
@@ -130,6 +146,8 @@ public class SecretMirrorStatusReporterTests : IAsyncLifetime, IDisposable
|
||||
Assert.Single(await _storage.GetSecretMirrorStatusesAsync());
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a probe prunes nothing during the start-up grace period and prunes once it has passed.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task Probe_DuringTheStartUpGrace_PrunesNothing_ThenPrunesAfterIt()
|
||||
{
|
||||
@@ -151,6 +169,8 @@ public class SecretMirrorStatusReporterTests : IAsyncLifetime, IDisposable
|
||||
Assert.Empty(await _storage.GetSecretMirrorStatusesAsync());
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a conditional delete does not remove a row the node rewrote after it was read.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ConditionalDelete_DoesNotRemoveARowTheNodeRewroteAfterTheRead()
|
||||
{
|
||||
@@ -168,12 +188,15 @@ public class SecretMirrorStatusReporterTests : IAsyncLifetime, IDisposable
|
||||
|
||||
private sealed class MutableTime(DateTimeOffset now) : TimeProvider
|
||||
{
|
||||
/// <summary>Gets or sets the instant that the clock reports.</summary>
|
||||
public DateTimeOffset Now { get; set; } = now;
|
||||
/// <inheritdoc />
|
||||
public override DateTimeOffset GetUtcNow() => Now;
|
||||
}
|
||||
|
||||
private sealed class FixedTime(DateTimeOffset now) : TimeProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override DateTimeOffset GetUtcNow() => now;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user