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:
@@ -7,8 +7,8 @@ using ZB.MOM.WW.ScadaBridge.CLI;
|
||||
namespace ZB.MOM.WW.ScadaBridge.CLI.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Regression tests for CLI-013 — <see cref="ManagementHttpClient.SendCommandAsync"/>
|
||||
/// (success, error-body parsing, connection-failure, and timeout paths) was untested.
|
||||
/// Regression tests for <see cref="ManagementHttpClient.SendCommandAsync"/>
|
||||
/// (success, error-body parsing, connection-failure, and timeout paths), which were previously untested.
|
||||
/// Uses a stub <see cref="HttpMessageHandler"/> so no live server is required.
|
||||
/// </summary>
|
||||
public class ManagementHttpClientTests
|
||||
@@ -17,6 +17,9 @@ public class ManagementHttpClientTests
|
||||
{
|
||||
private readonly Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> _responder;
|
||||
|
||||
/// <summary>Creates a handler that always answers with the given status code and JSON body.</summary>
|
||||
/// <param name="status">The HTTP status code to return.</param>
|
||||
/// <param name="body">The JSON response body to return.</param>
|
||||
public StubHandler(HttpStatusCode status, string body)
|
||||
: this((_, _) => Task.FromResult(new HttpResponseMessage(status)
|
||||
{
|
||||
@@ -25,11 +28,14 @@ public class ManagementHttpClientTests
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Creates a handler that delegates every request to the supplied responder.</summary>
|
||||
/// <param name="responder">The delegate that produces the response for each request.</param>
|
||||
public StubHandler(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> responder)
|
||||
{
|
||||
_responder = responder;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Task<HttpResponseMessage> SendAsync(
|
||||
HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
=> _responder(request, cancellationToken);
|
||||
@@ -38,6 +44,8 @@ public class ManagementHttpClientTests
|
||||
private static ManagementHttpClient ClientWith(StubHandler handler)
|
||||
=> new(new HttpClient(handler), "http://localhost:9001", "user", "pass");
|
||||
|
||||
/// <summary>Verifies that a successful response is returned as a success result carrying the JSON data.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task SendCommandAsync_Success_ReturnsJsonData()
|
||||
{
|
||||
@@ -51,6 +59,8 @@ public class ManagementHttpClientTests
|
||||
Assert.Null(response.ErrorCode);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an error response body is parsed into the error message and error code.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task SendCommandAsync_ErrorBody_ParsesErrorAndCode()
|
||||
{
|
||||
@@ -65,6 +75,8 @@ public class ManagementHttpClientTests
|
||||
Assert.Equal("INVALID_ARGUMENT", response.ErrorCode);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a non-JSON error body falls back to the raw body text as the error.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task SendCommandAsync_NonJsonErrorBody_FallsBackToRawBody()
|
||||
{
|
||||
@@ -78,6 +90,8 @@ public class ManagementHttpClientTests
|
||||
Assert.Null(response.ErrorCode);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a connection failure returns a result with status code zero.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task SendCommandAsync_ConnectionFailure_ReturnsStatusZero()
|
||||
{
|
||||
@@ -91,6 +105,8 @@ public class ManagementHttpClientTests
|
||||
Assert.Contains("connection refused", response.Error);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a timed-out call returns a 504 status.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task SendCommandAsync_Timeout_Returns504()
|
||||
{
|
||||
@@ -125,6 +141,7 @@ public class ManagementHttpClientTimeoutTests
|
||||
{
|
||||
private const string EnvVar = "SCADABRIDGE_HTTP_CONNECT_TIMEOUT_SECONDS";
|
||||
|
||||
/// <summary>Verifies that the default constructor leaves the underlying client timeout infinite.</summary>
|
||||
[Fact]
|
||||
public void DefaultConstructor_LeavesClientTimeoutInfinite()
|
||||
{
|
||||
@@ -133,6 +150,7 @@ public class ManagementHttpClientTimeoutTests
|
||||
Assert.Equal(Timeout.InfiniteTimeSpan, client.EffectiveTimeout);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the connect timeout defaults to thirty seconds when the environment variable is unset.</summary>
|
||||
[Fact]
|
||||
public void ConnectTimeout_DefaultsToThirtySeconds_WhenEnvVarUnset()
|
||||
{
|
||||
@@ -150,6 +168,8 @@ public class ManagementHttpClientTimeoutTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an invalid or non-positive environment value falls back to the default connect timeout.</summary>
|
||||
/// <param name="value">The environment variable value to test.</param>
|
||||
[Theory]
|
||||
[InlineData("0")]
|
||||
[InlineData("-5")]
|
||||
@@ -170,6 +190,7 @@ public class ManagementHttpClientTimeoutTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a positive environment variable value overrides the default connect timeout.</summary>
|
||||
[Fact]
|
||||
public void PositiveEnvValue_OverridesDefaultConnectTimeout()
|
||||
{
|
||||
@@ -195,6 +216,7 @@ public class ManagementHttpClientTimeoutTests
|
||||
/// real socket (not the stub handler) so the connect + send path is exercised
|
||||
/// end to end, and sub-second deadlines so the test stays fast.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PerCallTimeoutLongerThanTheOldClientCap_IsHonored()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user