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:
@@ -9,7 +9,7 @@ using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
|
||||
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for <see cref="AuditLogExportService"/> (#23 M7-T14 / Bundle F). The
|
||||
/// Tests for <see cref="AuditLogExportService"/>. The
|
||||
/// service streams the filtered Audit Log query to a destination stream as
|
||||
/// RFC 4180 CSV. These tests pin:
|
||||
/// <list type="bullet">
|
||||
@@ -22,7 +22,7 @@ namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Services;
|
||||
/// </summary>
|
||||
public class AuditLogExportServiceTests
|
||||
{
|
||||
// C3 (Task 2.5): the export service reads canonical ZB.MOM.WW.Audit.AuditEvent rows
|
||||
// The export service reads canonical ZB.MOM.WW.Audit.AuditEvent rows
|
||||
// from IAuditLogRepository and decomposes each into the flat 21-column CSV shape;
|
||||
// build the canonical rows via the shared factory (domain fields ride in DetailsJson).
|
||||
private static AuditEvent SimpleEvent(string id, string? target = null, string? error = null)
|
||||
@@ -39,6 +39,8 @@ public class AuditLogExportServiceTests
|
||||
errorMessage: error,
|
||||
ingestedAtUtc: new DateTimeOffset(new DateTime(2026, 5, 20, 12, 0, 1, DateTimeKind.Utc)));
|
||||
|
||||
/// <summary>Verifies that exporting five rows writes a header line plus five data lines.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ExportAsync_FiveRows_WritesHeaderPlusFiveRows()
|
||||
{
|
||||
@@ -74,6 +76,8 @@ public class AuditLogExportServiceTests
|
||||
Assert.Equal(string.Empty, lines[6]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the CSV header contains all 24 columns in specification order.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ExportAsync_HeaderHasAll24Columns_InSpecOrder()
|
||||
{
|
||||
@@ -89,7 +93,7 @@ public class AuditLogExportServiceTests
|
||||
var header = csv.Split("\r\n")[0];
|
||||
var columns = header.Split(',');
|
||||
|
||||
// arch-review 2026-08-19 P6-7: ExecutionId/ParentExecutionId/SourceNode
|
||||
// ExecutionId/ParentExecutionId/SourceNode
|
||||
// were missing from this CSV (JSON/JSONL exports already carried them).
|
||||
Assert.Equal(24, columns.Length);
|
||||
Assert.Equal(new[]
|
||||
@@ -103,6 +107,8 @@ public class AuditLogExportServiceTests
|
||||
}, columns);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a field containing a comma is quoted and escaped.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ExportAsync_FieldWithComma_QuotedAndEscaped()
|
||||
{
|
||||
@@ -139,10 +145,12 @@ public class AuditLogExportServiceTests
|
||||
Assert.Contains("\"boom\r\nthen again\"", csv);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that free-text cells starting with formula characters are prefixed with a single quote.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ExportAsync_FreeTextLeadingFormulaCharacters_ArePrefixedWithQuote()
|
||||
{
|
||||
// arch-review 2026-08-19 P6-7 (CWE-1236): a free-text cell starting with
|
||||
// CSV formula injection guard: a free-text cell starting with
|
||||
// =, +, -, @, or TAB must be prefixed with a literal single quote so a
|
||||
// spreadsheet application renders it as inert text, not a formula/DDE
|
||||
// launch. Target, ErrorMessage, ResponseSummary, and Extra are
|
||||
@@ -176,6 +184,8 @@ public class AuditLogExportServiceTests
|
||||
Assert.Contains(",'@SUM(A1:A9)", dataLine);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that numeric and date columns are never prefixed with a quote.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ExportAsync_NumericAndDateColumns_NeverPrefixed()
|
||||
{
|
||||
@@ -210,6 +220,8 @@ public class AuditLogExportServiceTests
|
||||
Assert.StartsWith("2026-05-20", fields[1]); // OccurredAtUtc, unprefixed
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a null field is written as an empty cell.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ExportAsync_NullField_WrittenAsEmpty()
|
||||
{
|
||||
@@ -254,6 +266,8 @@ public class AuditLogExportServiceTests
|
||||
Assert.Equal(string.Empty, fields[23]); // ForwardState null
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a row count above the cap is truncated and a cap footer is appended.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ExportAsync_RowCountAboveCap_Truncates_AppendsCapFooter()
|
||||
{
|
||||
@@ -279,6 +293,8 @@ public class AuditLogExportServiceTests
|
||||
Assert.Equal("# Capped at 3 rows. Use the CLI for larger exports.", lines[4]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that cancelling the token stops the export mid-stream.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ExportAsync_CancellationToken_StopsMidStream()
|
||||
{
|
||||
@@ -310,11 +326,13 @@ public class AuditLogExportServiceTests
|
||||
await sut.ExportAsync(new AuditLogQueryFilter(), maxRows: 1000, ms, cts.Token));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the export paginates using the last row of each page as the cursor.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ExportAsync_PaginatesUsingLastRowAsCursor()
|
||||
{
|
||||
// Two pages of 2 rows each, then empty. The service must pass the last
|
||||
// row of page 1 as the cursor on the page-2 call.
|
||||
// row of page 1 as the cursor on the second-page call.
|
||||
AuditEvent Row(string id, DateTime occurredAt) => ScadaBridgeAuditEventFactory.Create(
|
||||
channel: AuditChannel.ApiOutbound,
|
||||
kind: AuditKind.ApiCall,
|
||||
|
||||
Reference in New Issue
Block a user