Skip to content

Commit ca14195

Browse files
nanotaboadaclaude
andcommitted
test(controller): normalize data-state vocabulary in tests (#452)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c8128b4 commit ca14195

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ This project uses famous football stadiums (A-Z) that hosted FIFA World Cup matc
5757
- Rename `ValidateAsync_SquadNumber_BelongsToPlayerBeingUpdated_ReturnsNoErrors` to `ValidateAsync_SquadNumberBelongsToPlayerBeingUpdated_ReturnsNoErrors` to align with the 3-segment naming convention for service/validator tests (#427)
5858
- Make CSharpier step in `/pre-commit` conditional (skip with a note if not installed), consistent with the Docker and CodeRabbit steps (#427)
5959
- Add "Verify tag commit is reachable from master" step to CD workflow using `git merge-base --is-ancestor` before any build or publish steps (#439)
60+
- Rename five controller test methods to normalize data-state vocabulary: `NonExisting``Nonexistent` for the POST 201 scenario, `NonExisting``Unknown` for the four 404-by-lookup scenarios (#452)
61+
- Add XML doc `<remarks>` block to `PlayerFakes` documenting the three-term data-state vocabulary (`existing`, `nonexistent`, `unknown`) (#452)
6062

6163
### Fixed
6264

test/Dotnet.Samples.AspNetCore.WebApi.Tests/Unit/PlayerControllerTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public async Task Post_Players_Existing_Returns409Conflict()
109109

110110
[Fact]
111111
[Trait("Category", "Unit")]
112-
public async Task Post_Players_NonExisting_Returns201Created()
112+
public async Task Post_Players_Nonexistent_Returns201Created()
113113
{
114114
// Arrange
115115
var request = PlayerFakes.MakeRequestModelForCreate();
@@ -203,7 +203,7 @@ public async Task Get_Players_Empty_Returns200OkWithEmptyList()
203203

204204
[Fact]
205205
[Trait("Category", "Unit")]
206-
public async Task Get_PlayerById_NonExisting_Returns404NotFound()
206+
public async Task Get_PlayerById_Unknown_Returns404NotFound()
207207
{
208208
// Arrange
209209
var id = Guid.NewGuid();
@@ -248,7 +248,7 @@ public async Task Get_PlayerById_Existing_Returns200OK()
248248

249249
[Fact]
250250
[Trait("Category", "Unit")]
251-
public async Task Get_PlayerBySquadNumber_NonExisting_Returns404NotFound()
251+
public async Task Get_PlayerBySquadNumber_Unknown_Returns404NotFound()
252252
{
253253
// Arrange
254254
var squadNumber = 999;
@@ -345,7 +345,7 @@ public async Task Put_PlayerBySquadNumber_ValidationError_Returns400BadRequest()
345345

346346
[Fact]
347347
[Trait("Category", "Unit")]
348-
public async Task Put_PlayerBySquadNumber_NonExisting_Returns404NotFound()
348+
public async Task Put_PlayerBySquadNumber_Unknown_Returns404NotFound()
349349
{
350350
// Arrange
351351
var squadNumber = 999;
@@ -461,7 +461,7 @@ public async Task Put_PlayerBySquadNumber_Existing_Returns204NoContent()
461461

462462
[Fact]
463463
[Trait("Category", "Unit")]
464-
public async Task Delete_PlayerBySquadNumber_NonExisting_Returns404NotFound()
464+
public async Task Delete_PlayerBySquadNumber_Unknown_Returns404NotFound()
465465
{
466466
// Arrange
467467
var squadNumber = 999;

test/Dotnet.Samples.AspNetCore.WebApi.Tests/Utilities/PlayerFakes.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ namespace Dotnet.Samples.AspNetCore.WebApi.Tests.Utilities;
1212
/// useful when you need behavior that's closer to reality but still want
1313
/// to avoid external dependencies.
1414
/// </summary>
15+
/// <remarks>
16+
/// Data-state vocabulary used across controller tests:
17+
/// <list type="bullet">
18+
/// <item><term>existing</term><description>Player is present in the database.</description></item>
19+
/// <item><term>nonexistent</term><description>Player is absent, valid shape for creation (POST scenarios).</description></item>
20+
/// <item><term>unknown</term><description>Valid ID format, absent from database (404-by-lookup scenarios).</description></item>
21+
/// </list>
22+
/// </remarks>
1523
public static class PlayerFakes
1624
{
1725
private static string? FormatBirth(DateTime? dateOfBirth) =>

0 commit comments

Comments
 (0)