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:
@@ -34,6 +34,7 @@ public class SiteHealthCheckTests : IDisposable
|
||||
private readonly string _tempSiteDbPath;
|
||||
private readonly string _tempTrackingDbPath;
|
||||
|
||||
/// <summary>Initializes the test host with a temporary site database and the site health checks.</summary>
|
||||
public SiteHealthCheckTests()
|
||||
{
|
||||
var stamp = Guid.NewGuid();
|
||||
@@ -68,6 +69,7 @@ public class SiteHealthCheckTests : IDisposable
|
||||
_host = builder.Build();
|
||||
}
|
||||
|
||||
/// <summary>Releases the resources held by this instance.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
(_host as IDisposable)?.Dispose();
|
||||
@@ -82,6 +84,7 @@ public class SiteHealthCheckTests : IDisposable
|
||||
private IReadOnlyList<HealthCheckRegistration> Registrations =>
|
||||
_host.Services.GetRequiredService<IOptions<HealthCheckServiceOptions>>().Value.Registrations.ToList();
|
||||
|
||||
/// <summary>Verifies that a site registers exactly the three site health checks.</summary>
|
||||
[Fact]
|
||||
public void Site_RegistersExactlyTheThreeSiteChecks()
|
||||
{
|
||||
@@ -93,6 +96,9 @@ public class SiteHealthCheckTests : IDisposable
|
||||
Registrations.Select(r => r.Name).OrderBy(n => n, StringComparer.Ordinal).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>Verifies that each site check carries its intended tier tag.</summary>
|
||||
/// <param name="name">The health check registration name.</param>
|
||||
/// <param name="expectedTag">The tier tag the check is expected to carry.</param>
|
||||
[Theory]
|
||||
[InlineData("akka-cluster", ZbHealthTags.Ready)]
|
||||
[InlineData("localdb", ZbHealthTags.Ready)]
|
||||
@@ -106,6 +112,9 @@ public class SiteHealthCheckTests : IDisposable
|
||||
Assert.Equal(new[] { expectedTag }, registration.Tags.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>Verifies that each site check resolves to its intended implementation type.</summary>
|
||||
/// <param name="name">The health check registration name.</param>
|
||||
/// <param name="expected">The expected check implementation type.</param>
|
||||
[Theory]
|
||||
[InlineData("akka-cluster", typeof(AkkaClusterHealthCheck))]
|
||||
[InlineData("localdb", typeof(SiteLocalDbHealthCheck))]
|
||||
@@ -121,6 +130,7 @@ public class SiteHealthCheckTests : IDisposable
|
||||
Assert.IsType(expected, check);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the site active-node check is role-scoped and is not the unscoped central check.</summary>
|
||||
[Fact]
|
||||
public void Site_ActiveNodeCheck_IsRoleScoped_NotTheUnscopedCentralCheck()
|
||||
{
|
||||
@@ -136,6 +146,8 @@ public class SiteHealthCheckTests : IDisposable
|
||||
Assert.IsNotType<ActiveNodeHealthCheck>(check);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a site does not register central-only health checks.</summary>
|
||||
/// <param name="centralOnlyName">The name of a check that only central should register.</param>
|
||||
[Theory]
|
||||
[InlineData("database")]
|
||||
[InlineData("required-singletons")]
|
||||
@@ -148,6 +160,8 @@ public class SiteHealthCheckTests : IDisposable
|
||||
Assert.DoesNotContain(Registrations, r => r.Name == centralOnlyName);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the LocalDb check reports healthy against the real site database.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task Site_LocalDbCheck_ReportsHealthyAgainstTheRealSiteDatabase()
|
||||
{
|
||||
@@ -161,6 +175,8 @@ public class SiteHealthCheckTests : IDisposable
|
||||
Assert.Equal(HealthStatus.Healthy, result.Status);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the LocalDb check adds replication state without failing when replication is off by default.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task Site_LocalDbCheck_EnrichesWithReplicationStateWithoutFailingOnDefaultOff()
|
||||
{
|
||||
@@ -176,6 +192,8 @@ public class SiteHealthCheckTests : IDisposable
|
||||
Assert.Equal(0L, Assert.IsType<long>(result.Data["replicationOplogBacklog"]));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the LocalDb check reports unhealthy when the store is unreachable.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task Site_LocalDbCheck_ReportsUnhealthyWhenTheStoreIsUnreachable()
|
||||
{
|
||||
@@ -186,6 +204,10 @@ public class SiteHealthCheckTests : IDisposable
|
||||
Assert.Equal(HealthStatus.Unhealthy, result.Status);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the active-node check separates the primary from the standby.</summary>
|
||||
/// <param name="selfIsPrimary">Whether this node is the primary.</param>
|
||||
/// <param name="expected">The health status the check is expected to report.</param>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Theory]
|
||||
[InlineData(true, HealthStatus.Healthy)]
|
||||
[InlineData(false, HealthStatus.Unhealthy)]
|
||||
@@ -207,16 +229,30 @@ public class SiteHealthCheckTests : IDisposable
|
||||
|
||||
private sealed class StubNodeProvider(bool selfIsPrimary) : IClusterNodeProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool SelfIsPrimary { get; } = selfIsPrimary;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<NodeStatus> GetClusterNodes() => [];
|
||||
}
|
||||
|
||||
private sealed class ThrowingLocalDb : ILocalDb
|
||||
{
|
||||
/// <summary>Always throws to simulate an unreachable store.</summary>
|
||||
/// <param name="sql">The SQL text (ignored).</param>
|
||||
/// <param name="parameters">The statement parameters (ignored).</param>
|
||||
/// <param name="ct">A token to cancel the operation (ignored).</param>
|
||||
/// <returns>Never returns; always throws <see cref="InvalidOperationException"/>.</returns>
|
||||
public Task<int> ExecuteAsync(string sql, object? parameters = null, CancellationToken ct = default) =>
|
||||
throw new InvalidOperationException("store unreachable");
|
||||
|
||||
/// <summary>Always throws to simulate an unreachable store.</summary>
|
||||
/// <typeparam name="T">The row type.</typeparam>
|
||||
/// <param name="sql">The SQL text (ignored).</param>
|
||||
/// <param name="map">The row mapper (ignored).</param>
|
||||
/// <param name="parameters">The query parameters (ignored).</param>
|
||||
/// <param name="ct">A token to cancel the operation (ignored).</param>
|
||||
/// <returns>Never returns; always throws <see cref="InvalidOperationException"/>.</returns>
|
||||
public Task<IReadOnlyList<T>> QueryAsync<T>(
|
||||
string sql,
|
||||
Func<Microsoft.Data.Sqlite.SqliteDataReader, T> map,
|
||||
@@ -224,21 +260,37 @@ public class SiteHealthCheckTests : IDisposable
|
||||
CancellationToken ct = default) =>
|
||||
throw new InvalidOperationException("store unreachable");
|
||||
|
||||
/// <summary>Always throws to simulate an unreachable store.</summary>
|
||||
/// <param name="ct">A token to cancel the operation (ignored).</param>
|
||||
/// <returns>Never returns; always throws <see cref="InvalidOperationException"/>.</returns>
|
||||
public Task<ILocalDbTransaction> BeginTransactionAsync(CancellationToken ct = default) =>
|
||||
throw new InvalidOperationException("store unreachable");
|
||||
|
||||
/// <summary>Always throws to simulate an unreachable store.</summary>
|
||||
/// <returns>Never returns; always throws <see cref="InvalidOperationException"/>.</returns>
|
||||
public Microsoft.Data.Sqlite.SqliteConnection CreateConnection() =>
|
||||
throw new InvalidOperationException("store unreachable");
|
||||
|
||||
/// <summary>Always throws to simulate an unreachable store.</summary>
|
||||
/// <param name="tableName">The table name (ignored).</param>
|
||||
/// <returns>Never returns; always throws <see cref="InvalidOperationException"/>.</returns>
|
||||
public ReplicatedTable RegisterReplicated(string tableName) =>
|
||||
throw new InvalidOperationException("store unreachable");
|
||||
|
||||
/// <summary>Always throws to simulate an unreachable store.</summary>
|
||||
/// <param name="tableName">The table name (ignored).</param>
|
||||
/// <param name="baselineExistingRows">Whether to baseline existing rows (ignored).</param>
|
||||
/// <returns>Never returns; always throws <see cref="InvalidOperationException"/>.</returns>
|
||||
public ReplicatedTable RegisterReplicated(string tableName, bool baselineExistingRows) =>
|
||||
throw new InvalidOperationException("store unreachable");
|
||||
|
||||
/// <summary>Always throws to simulate an unreachable store.</summary>
|
||||
/// <param name="tableName">The table name (ignored).</param>
|
||||
/// <returns>Never returns; always throws <see cref="InvalidOperationException"/>.</returns>
|
||||
public bool DeregisterReplicated(string tableName) =>
|
||||
throw new InvalidOperationException("store unreachable");
|
||||
|
||||
/// <summary>Gets the replicated tables; always throws to simulate an unreachable store.</summary>
|
||||
public IReadOnlyDictionary<string, ReplicatedTable> ReplicatedTables =>
|
||||
throw new InvalidOperationException("store unreachable");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user