Add DisposeHelper unit tests - #10649
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Note
🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.
Review Summary
| # | Dimension | Verdict |
|---|---|---|
| 1 | Algorithmic Correctness | ✅ Pass — tests correctly verify all branches of DisposeHelper.DisposeAsync (null, non-disposable, sync dispose, async dispose, cleanup-then-dispose ordering, exception propagation). |
| 2 | Threading & Concurrency | N/A — test helpers are single-threaded by design. |
| 3 | Security & IPC Contract Safety | N/A — no IPC or security-sensitive code. |
| 4 | Public API & Binary Compatibility | N/A — test-only change, no public API surface. |
| 5 | Performance & Allocations | N/A — test code, not hot-path. |
| 6 | Cross-TFM Compatibility | ✅ Pass — #if NETCOREAPP guards correctly mirror the production code's conditional compilation for IAsyncDisposable. |
| 7 | Test Quality | ✅ Pass — good coverage of happy path, null input, exception propagation (both cleanup and dispose), double-dispose idempotency, and async-preferred-over-sync ordering. Uses MSTest Assert (correct per BannedSymbols.txt). |
| 8–22 | Remaining dimensions | N/A — no localization, no MSBuild changes, no CLI options, no documentation, no style violations detected. |
Verdict: No issues found. The tests are well-structured, correctly use Assert.AreSequenceEqual for invocation-order verification, and the recording test doubles are minimal and clear.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Adds direct multi-target unit coverage for the linked-source DisposeHelper.
Changes:
- Tests cleanup/disposal ordering and repeated invocation.
- Tests exception, cancellation, and target-specific disposal behavior.
- Links
DisposeHelper.csinto the unit-test project.
Show a summary per file
| File | Description |
|---|---|
DisposeHelperTests.cs |
Adds comprehensive disposal behavior tests. |
Microsoft.Testing.Platform.UnitTests.csproj |
Links the embedded helper source for testing. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🤖 Automated content by GitHub Copilot. Generated by the Test Reviewer on PR (on open / sync) workflow. · auto · 85.2 AIC · ⌖ 5.21 AIC · ⊞ 16.9K · ◷
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🧪 Expert test review — PR #10649
This advisory comment was generated automatically. Grades are heuristic
|
🧵 Parallel-safety audit — PR #10649Nothing audited here touches process-global state, shared filesystem paths, or The only change is a new Audited Re-run with
|
There was a problem hiding this comment.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
test/UnitTests/Microsoft.Testing.Platform.UnitTests/Helpers/DisposeHelperTests.cs:103
ValueTask.FromExceptioncreates a faulted operation, even when its exception is anOperationCanceledException, so this test does not exercise the canceled-ValueTaskbehavior named here and claimed by the PR. Construct the value withFromCanceledand use the derived-type assertion because awaiting it can throwTaskCanceledException.
RecordingAsyncResource resource = new(() => ValueTask.FromException(expectedException));
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Summary
DisposeHelperValidation
Microsoft.Testing.Platform.UnitTestssuite:Closes #10646