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:
+39
-3
@@ -12,7 +12,7 @@ using ProtoPullResponse = ZB.MOM.WW.ScadaBridge.Communication.Grpc.PullAuditEven
|
||||
namespace ZB.MOM.WW.ScadaBridge.AuditLog.Tests.Central;
|
||||
|
||||
/// <summary>
|
||||
/// Bundle (M6) tests for <see cref="GrpcPullAuditEventsClient"/> — the
|
||||
/// Tests for <see cref="GrpcPullAuditEventsClient"/> — the
|
||||
/// production <see cref="IPullAuditEventsClient"/> that dials a site over gRPC
|
||||
/// and issues the <c>PullAuditEvents</c> unary RPC for the reconciliation loop.
|
||||
/// The real <c>GrpcChannel</c> is replaced by an injected
|
||||
@@ -29,7 +29,10 @@ public class GrpcPullAuditEventsClientTests
|
||||
private sealed class StaticEnumerator : ISiteEnumerator
|
||||
{
|
||||
private readonly IReadOnlyList<SiteEntry> _sites;
|
||||
/// <summary>Initializes the enumerator with the fixed set of sites it will return.</summary>
|
||||
/// <param name="sites">The sites the enumerator returns on every call.</param>
|
||||
public StaticEnumerator(params SiteEntry[] sites) => _sites = sites;
|
||||
/// <inheritdoc />
|
||||
public Task<IReadOnlyList<SiteEntry>> EnumerateAsync(CancellationToken ct = default) =>
|
||||
Task.FromResult(_sites);
|
||||
}
|
||||
@@ -41,8 +44,11 @@ public class GrpcPullAuditEventsClientTests
|
||||
/// </summary>
|
||||
private sealed class FakeInvoker : GrpcPullAuditEventsClient.IPullAuditEventsInvoker
|
||||
{
|
||||
/// <summary>Gets the endpoint most recently dialed through this invoker.</summary>
|
||||
public string? Endpoint { get; private set; }
|
||||
/// <summary>Gets the request most recently passed to this invoker.</summary>
|
||||
public ProtoPullRequest? Request { get; private set; }
|
||||
/// <summary>Gets the number of times this invoker has been called.</summary>
|
||||
public int CallCount { get; private set; }
|
||||
|
||||
private readonly ProtoPullResponse? _response;
|
||||
@@ -54,9 +60,17 @@ public class GrpcPullAuditEventsClientTests
|
||||
_throw = toThrow;
|
||||
}
|
||||
|
||||
/// <summary>Creates an invoker that returns the given response.</summary>
|
||||
/// <param name="response">The response returned from every invocation.</param>
|
||||
/// <returns>An invoker that returns the given 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 thrown from every invocation.</param>
|
||||
/// <returns>An invoker that throws the given exception.</returns>
|
||||
public static FakeInvoker Throwing(Exception ex) => new(null, ex);
|
||||
|
||||
// Records the call and returns the canned response or throws the canned exception.
|
||||
/// <inheritdoc />
|
||||
public Task<ProtoPullResponse> InvokeAsync(
|
||||
string siteId, string endpoint, ProtoPullRequest request, CancellationToken ct)
|
||||
{
|
||||
@@ -72,17 +86,22 @@ public class GrpcPullAuditEventsClientTests
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Per-endpoint fake invoker (Task 18): routes dials by endpoint string so a
|
||||
/// Per-endpoint fake invoker: routes dials by endpoint string so a
|
||||
/// NodeA-down / NodeB-up failover can be scripted. Records dialed endpoints.
|
||||
/// </summary>
|
||||
private sealed class PerEndpointInvoker : GrpcPullAuditEventsClient.IPullAuditEventsInvoker
|
||||
{
|
||||
private readonly Dictionary<string, Func<ProtoPullResponse>> _byEndpoint;
|
||||
/// <summary>Gets the endpoints dialed so far, in call order.</summary>
|
||||
public List<string> Dialed { get; } = new();
|
||||
|
||||
/// <summary>Initializes the invoker with the scripted response factory for each endpoint.</summary>
|
||||
/// <param name="byEndpoint">The response factory keyed by endpoint address.</param>
|
||||
public PerEndpointInvoker(Dictionary<string, Func<ProtoPullResponse>> byEndpoint) =>
|
||||
_byEndpoint = byEndpoint;
|
||||
|
||||
// Records the dialed endpoint and returns the response scripted for it.
|
||||
/// <inheritdoc />
|
||||
public Task<ProtoPullResponse> InvokeAsync(
|
||||
string siteId, string endpoint, ProtoPullRequest request, CancellationToken ct)
|
||||
{
|
||||
@@ -100,6 +119,8 @@ public class GrpcPullAuditEventsClientTests
|
||||
status: AuditStatus.Delivered,
|
||||
sourceSiteId: "site-a"));
|
||||
|
||||
/// <summary>Verifies that the pull dials the resolved endpoint and maps the returned events oldest first.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_dials_the_resolved_endpoint_and_maps_events_oldest_first()
|
||||
{
|
||||
@@ -132,6 +153,8 @@ public class GrpcPullAuditEventsClientTests
|
||||
Assert.Equal(newer, result.Events[1].EventId);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that pulling from a site with no known endpoint returns an empty response.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_returns_empty_when_site_endpoint_is_unknown()
|
||||
{
|
||||
@@ -148,6 +171,9 @@ public class GrpcPullAuditEventsClientTests
|
||||
Assert.Equal(0, invoker.CallCount); // never dialled — nothing to dial
|
||||
}
|
||||
|
||||
/// <summary>Verifies that tolerable transport faults are swallowed and produce an empty response.</summary>
|
||||
/// <param name="code">The gRPC status code the invoker fails with.</param>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Theory]
|
||||
[InlineData(StatusCode.Unavailable)] // connection refused / site offline
|
||||
[InlineData(StatusCode.DeadlineExceeded)] // slow site / network blip
|
||||
@@ -167,6 +193,8 @@ public class GrpcPullAuditEventsClientTests
|
||||
Assert.False(result.MoreAvailable);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that connection-layer faults are swallowed and produce 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()
|
||||
{
|
||||
@@ -184,6 +212,8 @@ public class GrpcPullAuditEventsClientTests
|
||||
Assert.False(result.MoreAvailable);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that unexpected faults are swallowed and produce an empty response.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_swallows_unexpected_faults_to_empty_response()
|
||||
{
|
||||
@@ -203,6 +233,8 @@ public class GrpcPullAuditEventsClientTests
|
||||
Assert.False(result.MoreAvailable);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an unspecified minimum-value cursor does not throw and the site is still dialed.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PullAsync_with_minvalue_unspecified_cursor_does_not_throw_and_dials()
|
||||
{
|
||||
@@ -233,10 +265,12 @@ public class GrpcPullAuditEventsClientTests
|
||||
Assert.False(result.MoreAvailable);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the pull fails over to the secondary node 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 events rather than collapsing to empty.
|
||||
var id = Guid.NewGuid();
|
||||
var fallbackResponse = new ProtoPullResponse { MoreAvailable = false };
|
||||
@@ -259,6 +293,8 @@ public class GrpcPullAuditEventsClientTests
|
||||
Assert.Equal(id, evt.EventId);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that no failover is attempted when the site has no fallback endpoint 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