Fix stale validation-guard comment in the Todo sample controller tests - #19
Merged
Merged
Conversation
The Create endpoint tests described the missing-required-field guard as CreateTodoCommandValidator.NotNull() in the FluentValidation pipeline, but CreateTodoCommandValidator is an empty showcase stub. The actual guard is CreateTodoCommand.TryCreate(...) — Result.Ensure(title is not null, ...) returns 422 before the handler runs. Corrected the comment in both API-version test copies to match the shipped code.
There was a problem hiding this comment.
Pull request overview
This PR updates the explanatory comment in the Todo sample controller tests to correctly describe where the “missing required field” guard happens (in CreateTodoCommand.TryCreate(...), not in CreateTodoCommandValidator), aligning the test narrative with the shipped implementation without changing behavior.
Changes:
- Corrected the comment to reference
CreateTodoCommand.TryCreate(...)as the source of the 422 guard for missingTitle. - Applied the same correction to both API-versioned test snapshots (
2026-03-26and2026-12-01).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| asp/template/Api/tests/2026-12-01/TodosControllerTests.cs | Updates the missing-title guard comment to match the controller’s TryCreate(...) usage. |
| asp/template/Api/tests/2026-03-26/TodosControllerTests.cs | Same comment correction in the older API-versioned test snapshot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CreateTodoCommandValidatoris an empty showcase stub (its only content is a commented example of a DI/async rule), so the Create endpoint's controller tests were describing the missing-required-field guard incorrectly. The real guard isCreateTodoCommand.TryCreate(...)—Result.Ensure(title is not null, ...)returns 422 before the handler runs.Corrected the comment in both API-version test copies (
2026-03-26+2026-12-01) to match the shipped code. Comment-only change; no behavior affected.(Surfaced by a Copilot review of a scaffold generated from this template.)