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:
@@ -22,7 +22,7 @@ using System.Text;
|
||||
namespace ZB.MOM.WW.ScadaBridge.InboundAPI.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// InboundAPI-020: the inbound API handler must accept JSON content types
|
||||
/// The inbound API handler must accept JSON content types
|
||||
/// case-insensitively. A request with <c>application/JSON</c>,
|
||||
/// <c>Application/Json</c>, or <c>application/json</c> must all enter the
|
||||
/// JSON-deserialization path — the previous <c>Contains("json")</c> check
|
||||
@@ -46,6 +46,9 @@ public sealed class EndpointContentTypeTests : IDisposable
|
||||
private readonly string _sqlitePath =
|
||||
Path.Combine(Path.GetTempPath(), $"inbound-api-keys-ct-{Guid.NewGuid():N}.sqlite");
|
||||
|
||||
/// <summary>Verifies that the content-type check is case-insensitive and the body is parsed for any casing.</summary>
|
||||
/// <param name="contentType">The JSON content type in the casing under test.</param>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Theory]
|
||||
[InlineData("application/json")]
|
||||
[InlineData("application/JSON")]
|
||||
@@ -92,10 +95,12 @@ public sealed class EndpointContentTypeTests : IDisposable
|
||||
Assert.Contains("42", body);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a body with a non-JSON content type is rejected with 415.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task NonJsonContentType_WithBody_Returns415()
|
||||
{
|
||||
// Task 5 (S9): a body with a non-JSON Content-Type must be rejected with 415 +
|
||||
// A body with a non-JSON Content-Type must be rejected with 415 +
|
||||
// UNSUPPORTED_MEDIA_TYPE rather than a misleading 400 "invalid JSON". A body
|
||||
// with NO Content-Type header is still parsed leniently as JSON (preserving
|
||||
// existing callers).
|
||||
@@ -187,7 +192,7 @@ public sealed class EndpointContentTypeTests : IDisposable
|
||||
services.AddRouting();
|
||||
services.AddSingleton(repo);
|
||||
// RouteHelper depends on IInstanceLocator + IInstanceRouter
|
||||
// (InboundAPI-017). Tests for content-type handling never
|
||||
// . Tests for content-type handling never
|
||||
// route, so both can be no-op stubs.
|
||||
services.AddSingleton(Substitute.For<IInstanceLocator>());
|
||||
services.Configure<InboundApiOptions>(_ => { });
|
||||
@@ -207,6 +212,7 @@ public sealed class EndpointContentTypeTests : IDisposable
|
||||
return await hostBuilder.StartAsync();
|
||||
}
|
||||
|
||||
/// <summary>Releases the resources used by this instance.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
@@ -227,6 +233,8 @@ public sealed class EndpointContentTypeTests : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a chunked non-JSON body is rejected with 415.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ChunkedNonJsonBody_Returns415()
|
||||
{
|
||||
@@ -261,6 +269,8 @@ public sealed class EndpointContentTypeTests : IDisposable
|
||||
Assert.Contains("UNSUPPORTED_MEDIA_TYPE", body);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a chunked JSON body with no content type is still parsed leniently.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ChunkedJsonBody_NoContentType_StillParsesLeniently()
|
||||
{
|
||||
@@ -302,10 +312,12 @@ public sealed class EndpointContentTypeTests : IDisposable
|
||||
/// </summary>
|
||||
private sealed class ChunkedByteContent(byte[] bytes) : HttpContent
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override Task SerializeToStreamAsync(
|
||||
Stream stream, System.Net.TransportContext? context) =>
|
||||
stream.WriteAsync(bytes, 0, bytes.Length);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool TryComputeLength(out long length)
|
||||
{
|
||||
length = -1;
|
||||
|
||||
Reference in New Issue
Block a user