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,6 +11,7 @@ public class SharedScriptServiceTests
|
||||
private readonly Mock<IAuditService> _auditMock;
|
||||
private readonly SharedScriptService _service;
|
||||
|
||||
/// <summary>Initializes the test class with mocked repository and audit services.</summary>
|
||||
public SharedScriptServiceTests()
|
||||
{
|
||||
_repoMock = new Mock<ITemplateEngineRepository>();
|
||||
@@ -19,6 +20,9 @@ public class SharedScriptServiceTests
|
||||
_service = new SharedScriptService(_repoMock.Object, _auditMock.Object);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that create and update both reject invalid code before saving.</summary>
|
||||
/// <param name="code">The invalid script code.</param>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Theory]
|
||||
[InlineData("return System.IO.File.ReadAllText(\"x\");")]
|
||||
[InlineData("return noSuchVariable;")]
|
||||
@@ -34,6 +38,8 @@ public class SharedScriptServiceTests
|
||||
_repoMock.Verify(r => r.SaveChangesAsync(It.IsAny<CancellationToken>()), Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that creating a shared script succeeds.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task CreateSharedScript_Success()
|
||||
{
|
||||
@@ -48,6 +54,8 @@ public class SharedScriptServiceTests
|
||||
_repoMock.Verify(r => r.AddSharedScriptAsync(It.IsAny<SharedScript>(), It.IsAny<CancellationToken>()), Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that creating a shared script with an empty name fails.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task CreateSharedScript_EmptyName_Fails()
|
||||
{
|
||||
@@ -56,6 +64,8 @@ public class SharedScriptServiceTests
|
||||
Assert.Contains("name is required", result.Error);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that creating a shared script with empty code fails.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task CreateSharedScript_EmptyCode_Fails()
|
||||
{
|
||||
@@ -64,6 +74,8 @@ public class SharedScriptServiceTests
|
||||
Assert.Contains("code is required", result.Error);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that creating a shared script with a duplicate name fails.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task CreateSharedScript_DuplicateName_Fails()
|
||||
{
|
||||
@@ -76,6 +88,8 @@ public class SharedScriptServiceTests
|
||||
Assert.Contains("already exists", result.Error);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that creating a shared script with unbalanced braces fails.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task CreateSharedScript_UnbalancedBraces_Fails()
|
||||
{
|
||||
@@ -88,6 +102,8 @@ public class SharedScriptServiceTests
|
||||
Assert.Contains("Syntax error", result.Error);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that updating a shared script succeeds.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task UpdateSharedScript_Success()
|
||||
{
|
||||
@@ -100,6 +116,8 @@ public class SharedScriptServiceTests
|
||||
Assert.Equal("return 42;", result.Value.Code);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that updating a shared script that does not exist fails.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task UpdateSharedScript_NotFound_Fails()
|
||||
{
|
||||
@@ -111,6 +129,8 @@ public class SharedScriptServiceTests
|
||||
Assert.Contains("not found", result.Error);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that deleting a shared script succeeds.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task DeleteSharedScript_Success()
|
||||
{
|
||||
@@ -123,6 +143,8 @@ public class SharedScriptServiceTests
|
||||
_repoMock.Verify(r => r.DeleteSharedScriptAsync(1, It.IsAny<CancellationToken>()), Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that deleting a shared script that does not exist fails.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task DeleteSharedScript_NotFound_Fails()
|
||||
{
|
||||
@@ -136,6 +158,9 @@ public class SharedScriptServiceTests
|
||||
|
||||
// Syntax validation unit tests
|
||||
|
||||
/// <summary>Verifies that syntax validation of valid code returns the expected result.</summary>
|
||||
/// <param name="code">The script code to validate.</param>
|
||||
/// <param name="expected">The expected validation result, or null when the code is valid.</param>
|
||||
[Theory]
|
||||
[InlineData("return 42;", null)]
|
||||
[InlineData("public void Run() { }", null)]
|
||||
@@ -146,6 +171,8 @@ public class SharedScriptServiceTests
|
||||
Assert.Equal(expected, SharedScriptService.ValidateSyntax(code));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that syntax validation of invalid code returns an error.</summary>
|
||||
/// <param name="code">The invalid script code.</param>
|
||||
[Theory]
|
||||
[InlineData("public void Run() {")]
|
||||
[InlineData("return a + b);")]
|
||||
@@ -157,8 +184,10 @@ public class SharedScriptServiceTests
|
||||
Assert.Contains("Syntax error", result);
|
||||
}
|
||||
|
||||
// --- TemplateEngine-007 regression: string/comment-literal awareness ---
|
||||
// --- Regression: string/comment-literal awareness ---
|
||||
|
||||
/// <summary>Verifies that delimiters inside strings or comments do not cause a syntax validation error.</summary>
|
||||
/// <param name="code">The script code containing delimiters inside a string or comment.</param>
|
||||
[Theory]
|
||||
[InlineData("var s = \"a } brace\"; { }")] // brace inside a normal string
|
||||
[InlineData("var s = \"a ) paren ] bracket\";")] // paren/bracket inside a string
|
||||
@@ -172,14 +201,16 @@ public class SharedScriptServiceTests
|
||||
Assert.Null(SharedScriptService.ValidateSyntax(code));
|
||||
}
|
||||
|
||||
// --- TemplateEngine-020 regression: audit row carries the real script Id ---
|
||||
// --- Regression: audit row carries the real script Id ---
|
||||
|
||||
/// <summary>Verifies that the create audit row carries the real script id rather than a literal zero.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task CreateSharedScript_AuditRowCarriesRealScriptIdNotLiteralZero()
|
||||
{
|
||||
// Pre-020: AddSharedScriptAsync → LogAsync("0", ...) → SaveChangesAsync.
|
||||
// Before the fix: AddSharedScriptAsync → LogAsync("0", ...) → SaveChangesAsync.
|
||||
// The audit row was queued with EntityId = "0" because EF Core had
|
||||
// not yet populated the auto-generated key. Post-020: save first,
|
||||
// not yet populated the auto-generated key. After the fix: save first,
|
||||
// then log with the real Id, then save the audit row.
|
||||
_repoMock.Setup(r => r.GetSharedScriptByNameAsync("Helpers", It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync((SharedScript?)null);
|
||||
|
||||
Reference in New Issue
Block a user