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:
Joseph Doherty
2026-10-07 15:05:49 -04:00
parent 0ffd4bdbea
commit 513fa1aa16
998 changed files with 17896 additions and 2395 deletions
@@ -13,11 +13,14 @@ public class TemplateFolderServiceTests
private readonly Mock<IAuditService> _auditMock = new();
private readonly TemplateFolderService _sut;
/// <summary>Initializes the test class with a mocked repository and the service under test.</summary>
public TemplateFolderServiceTests()
{
_sut = new TemplateFolderService(_repoMock.Object, _auditMock.Object);
}
/// <summary>Verifies that creating a folder with valid input succeeds.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task CreateFolder_ValidInput_ReturnsSuccess()
{
@@ -30,10 +33,12 @@ public class TemplateFolderServiceTests
Assert.Equal("Dev", result.Value.Name);
Assert.Null(result.Value.ParentFolderId);
_repoMock.Verify(r => r.AddFolderAsync(It.IsAny<TemplateFolder>(), It.IsAny<CancellationToken>()), Times.Once);
// Two saves: the folder entity, then the staged audit row (TemplateEngine-024).
// Two saves: the folder entity, then the staged audit row.
_repoMock.Verify(r => r.SaveChangesAsync(It.IsAny<CancellationToken>()), Times.Exactly(2));
}
/// <summary>Verifies that creating a folder with an empty name fails.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task CreateFolder_EmptyName_ReturnsFailure()
{
@@ -43,6 +48,8 @@ public class TemplateFolderServiceTests
Assert.Contains("required", result.Error, StringComparison.OrdinalIgnoreCase);
}
/// <summary>Verifies that creating a folder whose name duplicates a sibling's, ignoring case, fails.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task CreateFolder_DuplicateSiblingName_CaseInsensitive_ReturnsFailure()
{
@@ -58,6 +65,8 @@ public class TemplateFolderServiceTests
Assert.Contains("already exists", result.Error);
}
/// <summary>Verifies that creating a folder under a missing parent fails.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task CreateFolder_ParentNotFound_ReturnsFailure()
{
@@ -70,6 +79,8 @@ public class TemplateFolderServiceTests
Assert.Contains("not found", result.Error);
}
/// <summary>Verifies that renaming a folder with valid input succeeds.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task RenameFolder_ValidInput_ReturnsSuccess()
{
@@ -84,6 +95,8 @@ public class TemplateFolderServiceTests
Assert.Equal("New", result.Value.Name);
}
/// <summary>Verifies that renaming a missing folder fails.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task RenameFolder_NotFound_ReturnsFailure()
{
@@ -95,6 +108,8 @@ public class TemplateFolderServiceTests
Assert.True(result.IsFailure);
}
/// <summary>Verifies that renaming a folder to a sibling's name fails.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task RenameFolder_DuplicateSibling_ReturnsFailure()
{
@@ -110,6 +125,8 @@ public class TemplateFolderServiceTests
Assert.Contains("already exists", result.Error);
}
/// <summary>Verifies that moving a folder under a valid parent succeeds.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task MoveFolder_ValidParent_ReturnsSuccess()
{
@@ -126,6 +143,8 @@ public class TemplateFolderServiceTests
Assert.Equal(2, result.Value.ParentFolderId);
}
/// <summary>Verifies that moving a folder onto itself fails.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task MoveFolder_OntoSelf_ReturnsFailure()
{
@@ -138,6 +157,8 @@ public class TemplateFolderServiceTests
Assert.Contains("cycle", result.Error, StringComparison.OrdinalIgnoreCase);
}
/// <summary>Verifies that moving a folder onto one of its descendants fails.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task MoveFolder_OntoDescendant_ReturnsFailure()
{
@@ -156,6 +177,8 @@ public class TemplateFolderServiceTests
Assert.Contains("cycle", result.Error, StringComparison.OrdinalIgnoreCase);
}
/// <summary>Verifies that moving a folder to the root succeeds.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task MoveFolder_ToRoot_ReturnsSuccess()
{
@@ -170,6 +193,8 @@ public class TemplateFolderServiceTests
Assert.Null(result.Value.ParentFolderId);
}
/// <summary>Verifies that moving a folder in a graph with a pre-existing cycle fails without looping forever.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task MoveFolder_PreExistingCycleInGraph_ReturnsFailure_DoesNotInfiniteLoop()
{
@@ -189,6 +214,8 @@ public class TemplateFolderServiceTests
Assert.Contains("cycle", result.Error, StringComparison.OrdinalIgnoreCase);
}
/// <summary>Verifies that deleting an empty folder succeeds.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task DeleteFolder_Empty_ReturnsSuccess()
{
@@ -205,6 +232,8 @@ public class TemplateFolderServiceTests
_repoMock.Verify(r => r.DeleteFolderAsync(1, It.IsAny<CancellationToken>()), Times.Once);
}
/// <summary>Verifies that deleting a folder with child folders fails and reports the counts.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task DeleteFolder_HasChildFolders_ReturnsFailure_WithCounts()
{
@@ -222,6 +251,8 @@ public class TemplateFolderServiceTests
Assert.Contains("1 subfolder", result.Error);
}
/// <summary>Verifies that deleting a folder that contains templates fails and reports the counts.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task DeleteFolder_HasTemplates_ReturnsFailure_WithCounts()
{
@@ -243,6 +274,8 @@ public class TemplateFolderServiceTests
// ReorderFolderAsync — sibling reorder by SortOrder (Up = lower, Down = higher)
// ========================================================================
/// <summary>Verifies that reordering a folder up swaps its sort order with the previous sibling.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ReorderFolder_Up_SwapsSortOrderWithPreviousSibling()
{
@@ -262,6 +295,8 @@ public class TemplateFolderServiceTests
Assert.Equal(2, c.SortOrder);
}
/// <summary>Verifies that reordering a folder down swaps its sort order with the next sibling.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ReorderFolder_Down_SwapsSortOrderWithNextSibling()
{
@@ -281,6 +316,8 @@ public class TemplateFolderServiceTests
Assert.Equal(1, c.SortOrder);
}
/// <summary>Verifies that reordering the top folder up is a no-op.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ReorderFolder_UpAtTop_IsNoOp()
{
@@ -302,6 +339,8 @@ public class TemplateFolderServiceTests
It.IsAny<string>(), It.IsAny<string>(), It.IsAny<object?>(), It.IsAny<CancellationToken>()), Times.Never);
}
/// <summary>Verifies that reordering the bottom folder down is a no-op.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ReorderFolder_DownAtBottom_IsNoOp()
{
@@ -320,6 +359,8 @@ public class TemplateFolderServiceTests
_repoMock.Verify(r => r.SaveChangesAsync(It.IsAny<CancellationToken>()), Times.Never);
}
/// <summary>Verifies that reordering only affects folders within the same parent.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ReorderFolder_OnlyReordersWithinSameParent()
{
@@ -343,6 +384,8 @@ public class TemplateFolderServiceTests
Assert.Equal(1, b.SortOrder);
}
/// <summary>Verifies that moving one of three siblings down and then up yields the expected order.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ReorderFolder_ThreeSiblings_DownThenUp_YieldsExpectedOrder()
{
@@ -367,6 +410,8 @@ public class TemplateFolderServiceTests
Assert.Equal(new[] { "B", "C", "A" }, ordered2);
}
/// <summary>Verifies that reordering a missing folder fails.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ReorderFolder_NotFound_ReturnsFailure()
{
@@ -383,6 +428,8 @@ public class TemplateFolderServiceTests
// CreateFolderAsync — distinct SortOrder assignment (max+1 among siblings)
// ========================================================================
/// <summary>Verifies that the first sibling folder gets sort order zero.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task CreateFolder_FirstSibling_GetsSortOrderZero()
{
@@ -401,6 +448,8 @@ public class TemplateFolderServiceTests
Assert.Equal(0, captured!.SortOrder);
}
/// <summary>Verifies that a second sibling folder under the same parent gets sort order one.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task CreateFolder_SecondSiblingUnderSameParent_GetsSortOrderOne()
{
@@ -420,6 +469,8 @@ public class TemplateFolderServiceTests
Assert.Equal(1, captured!.SortOrder);
}
/// <summary>Verifies that folder sort orders do not interfere across different parents.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task CreateFolder_SortOrdersDoNotInterferAcrossParents()
{
@@ -442,6 +493,8 @@ public class TemplateFolderServiceTests
Assert.Equal(0, captured!.SortOrder);
}
/// <summary>Verifies that reordering two sibling folders visibly changes their order.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task CreateFolder_TwoSiblingsReorderIsVisiblyEffective()
{
@@ -471,6 +524,8 @@ public class TemplateFolderServiceTests
_repoMock.Verify(r => r.UpdateFolderAsync(second, It.IsAny<CancellationToken>()), Times.Once);
}
/// <summary>Verifies that reordering a folder persists the change and writes an audit entry.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ReorderFolder_Persists_And_WritesAudit()
{
@@ -486,7 +541,7 @@ public class TemplateFolderServiceTests
// Both swapped siblings persisted.
_repoMock.Verify(r => r.UpdateFolderAsync(a, It.IsAny<CancellationToken>()), Times.Once);
_repoMock.Verify(r => r.UpdateFolderAsync(b, It.IsAny<CancellationToken>()), Times.Once);
// Two saves: the swapped siblings, then the staged audit row (TemplateEngine-024).
// Two saves: the swapped siblings, then the staged audit row.
_repoMock.Verify(r => r.SaveChangesAsync(It.IsAny<CancellationToken>()), Times.Exactly(2));
// Audit entry written (mirrors Move/Rename audit assertions).
_auditMock.Verify(au => au.LogAsync("admin", "Reorder", "TemplateFolder", "2", "B",
@@ -494,11 +549,13 @@ public class TemplateFolderServiceTests
}
// ========================================================================
// TemplateEngine-024 — each folder mutator must SaveChanges *after* LogAsync
// Each folder mutator must SaveChanges *after* LogAsync
// so the staged audit row is persisted (and not discarded when the scope is
// disposed). Verified by tracking call order across the mutators.
// ========================================================================
/// <summary>Verifies that creating a folder persists the audit row by saving after logging.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task CreateFolder_PersistsAuditRow_SaveFollowsLog()
{
@@ -508,6 +565,8 @@ public class TemplateFolderServiceTests
.ReturnsAsync(new List<TemplateFolder>())));
}
/// <summary>Verifies that renaming a folder persists the audit row by saving after logging.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task RenameFolder_PersistsAuditRow_SaveFollowsLog()
{
@@ -522,6 +581,8 @@ public class TemplateFolderServiceTests
}));
}
/// <summary>Verifies that moving a folder persists the audit row by saving after logging.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task MoveFolder_PersistsAuditRow_SaveFollowsLog()
{
@@ -538,6 +599,8 @@ public class TemplateFolderServiceTests
}));
}
/// <summary>Verifies that reordering a folder persists the audit row by saving after logging.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ReorderFolder_PersistsAuditRow_SaveFollowsLog()
{
@@ -553,6 +616,8 @@ public class TemplateFolderServiceTests
}));
}
/// <summary>Verifies that deleting a folder persists the audit row by saving after logging.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task DeleteFolder_PersistsAuditRow_SaveFollowsLog()
{
@@ -593,7 +658,7 @@ public class TemplateFolderServiceTests
/// <summary>
/// Asserts the mutator logged an audit entry and then issued a
/// <c>SaveChangesAsync</c> after it — proving the staged audit row is
/// persisted rather than discarded (TemplateEngine-024).
/// persisted rather than discarded.
/// </summary>
private static void AssertAuditRowPersisted(List<string> calls)
{