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:
@@ -11,7 +11,7 @@ namespace ZB.MOM.WW.ScadaBridge.AuditLog.Tests.Central;
|
||||
/// <summary>
|
||||
/// Tests for <see cref="GrpcPullSiteCallsClient"/> — the production
|
||||
/// <see cref="IPullSiteCallsClient"/> that dials a site over gRPC and issues the
|
||||
/// <c>PullSiteCalls</c> unary RPC for the Site Call Audit (#22) reconciliation
|
||||
/// <c>PullSiteCalls</c> unary RPC for the Site Call Audit reconciliation
|
||||
/// loop. The real <c>GrpcChannel</c> is replaced by an injected
|
||||
/// <see cref="GrpcPullSiteCallsClient.IPullSiteCallsInvoker"/> seam so the
|
||||
/// client's mapping / ordering / SourceSite-restamp / fault-swallowing behaviour
|
||||
@@ -26,15 +26,21 @@ public class GrpcPullSiteCallsClientTests
|
||||
private sealed class StaticEnumerator : ISiteEnumerator
|
||||
{
|
||||
private readonly IReadOnlyList<SiteEntry> _sites;
|
||||
/// <summary>Initializes a new instance of the <c>StaticEnumerator</c> class.</summary>
|
||||
/// <param name="sites">The sites.</param>
|
||||
public StaticEnumerator(params SiteEntry[] sites) => _sites = sites;
|
||||
/// <inheritdoc />
|
||||
public Task<IReadOnlyList<SiteEntry>> EnumerateAsync(CancellationToken ct = default) =>
|
||||
Task.FromResult(_sites);
|
||||
}
|
||||
|
||||
private sealed class FakeInvoker : GrpcPullSiteCallsClient.IPullSiteCallsInvoker
|
||||
{
|
||||
/// <summary>Gets the endpoint most recently dialed.</summary>
|
||||
public string? Endpoint { get; private set; }
|
||||
/// <summary>Gets the request most recently received.</summary>
|
||||
public ProtoPullRequest? Request { get; private set; }
|
||||
/// <summary>Gets the number of calls made.</summary>
|
||||
public int CallCount { get; private set; }
|
||||
|
||||
private readonly ProtoPullResponse? _response;
|
||||
@@ -46,9 +52,16 @@ public class GrpcPullSiteCallsClientTests
|
||||
_throw = toThrow;
|
||||
}
|
||||
|
||||
/// <summary>Creates an invoker that returns the given response.</summary>
|
||||
/// <param name="response">The response to return.</param>
|
||||
/// <returns>A fake invoker returning <paramref name="response"/>.</returns>
|
||||
public static FakeInvoker Returning(ProtoPullResponse response) => new(response, null);
|
||||
/// <summary>Creates an invoker that throws the given exception.</summary>
|
||||
/// <param name="ex">The exception to throw.</param>
|
||||
/// <returns>A fake invoker that throws <paramref name="ex"/>.</returns>
|
||||
public static FakeInvoker Throwing(Exception ex) => new(null, ex);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<ProtoPullResponse> InvokeAsync(
|
||||
string siteId, string endpoint, ProtoPullRequest request, CancellationToken ct)
|
||||
{
|
||||
@@ -64,18 +77,22 @@ public class GrpcPullSiteCallsClientTests
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Per-endpoint fake invoker (Task 18): dials are routed by endpoint string so
|
||||
/// Per-endpoint fake invoker: dials are routed by endpoint string so
|
||||
/// a NodeA-down / NodeB-up failover can be scripted. Records every dialed
|
||||
/// endpoint in order.
|
||||
/// </summary>
|
||||
private sealed class PerEndpointInvoker : GrpcPullSiteCallsClient.IPullSiteCallsInvoker
|
||||
{
|
||||
private readonly Dictionary<string, Func<ProtoPullResponse>> _byEndpoint;
|
||||
/// <summary>Gets the endpoints dialed, in order.</summary>
|
||||
public List<string> Dialed { get; } = new();
|
||||
|
||||
/// <summary>Initializes a new instance of the <c>PerEndpointInvoker</c> class.</summary>
|
||||
/// <param name="byEndpoint">The by endpoint.</param>
|
||||
public PerEndpointInvoker(Dictionary<string, Func<ProtoPullResponse>> byEndpoint) =>
|
||||
_byEndpoint = byEndpoint;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<ProtoPullResponse> InvokeAsync(
|
||||
string siteId, string endpoint, ProtoPullRequest request, CancellationToken ct)
|
||||
{
|
||||
@@ -103,6 +120,8 @@ public class GrpcPullSiteCallsClientTests
|
||||
UpdatedAtUtc = Timestamp.FromDateTime(updatedAtUtc),
|
||||
};
|
||||
|
||||
/// <summary>Verifies that PullAsync dials the resolved endpoint, maps rows oldest first and restamps the source site.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_dials_resolved_endpoint_maps_oldest_first_and_restamps_source_site()
|
||||
{
|
||||
@@ -144,6 +163,8 @@ public class GrpcPullSiteCallsClientTests
|
||||
Assert.Equal(1, result.SiteCalls[0].RetryCount);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that PullAsync returns an empty response when the site endpoint is unknown.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_returns_empty_when_site_endpoint_is_unknown()
|
||||
{
|
||||
@@ -160,6 +181,9 @@ public class GrpcPullSiteCallsClientTests
|
||||
Assert.Equal(0, invoker.CallCount); // never dialled — nothing to dial
|
||||
}
|
||||
|
||||
/// <summary>Verifies that PullAsync turns tolerable transport faults into an empty response.</summary>
|
||||
/// <param name="code">The code.</param>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Theory]
|
||||
[InlineData(StatusCode.Unavailable)]
|
||||
[InlineData(StatusCode.DeadlineExceeded)]
|
||||
@@ -178,6 +202,8 @@ public class GrpcPullSiteCallsClientTests
|
||||
Assert.False(result.MoreAvailable);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that PullAsync turns connection-layer faults into an empty response.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_swallows_connection_layer_faults_to_empty_response()
|
||||
{
|
||||
@@ -193,6 +219,8 @@ public class GrpcPullSiteCallsClientTests
|
||||
Assert.False(result.MoreAvailable);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that PullAsync turns unexpected faults into an empty response.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_swallows_unexpected_faults_to_empty_response()
|
||||
{
|
||||
@@ -208,6 +236,8 @@ public class GrpcPullSiteCallsClientTests
|
||||
Assert.False(result.MoreAvailable);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that PullAsync skips a poison row and still returns the good rows.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_skips_poison_row_and_returns_the_good_rows()
|
||||
{
|
||||
@@ -244,6 +274,8 @@ public class GrpcPullSiteCallsClientTests
|
||||
Assert.False(result.MoreAvailable);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that PullAsync with a MinValue unspecified-kind cursor does not throw and still dials the site.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_with_minvalue_unspecified_cursor_does_not_throw_and_dials()
|
||||
{
|
||||
@@ -271,10 +303,12 @@ public class GrpcPullSiteCallsClientTests
|
||||
Assert.False(result.MoreAvailable);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that PullAsync fails over to node B when the primary raises a transport fault.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_fails_over_to_NodeB_when_primary_raises_transport_fault()
|
||||
{
|
||||
// Task 18: NodeA (primary) is unreachable, NodeB (fallback) answers — the
|
||||
// NodeA (primary) is unreachable, NodeB (fallback) answers — the
|
||||
// pull must return NodeB's rows rather than collapsing to empty.
|
||||
var id = Guid.NewGuid();
|
||||
var fallbackResponse = new ProtoPullResponse();
|
||||
@@ -299,6 +333,8 @@ public class GrpcPullSiteCallsClientTests
|
||||
Assert.Equal("site-a", row.SourceSite);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that PullAsync does not fail over when no fallback is configured.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_does_not_fail_over_when_no_fallback_configured()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user