Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This project uses famous football stadiums (A-Z) that hosted FIFA World Cup matc

### Changed

- Field validation failures now return `422 Unprocessable Entity` (RFC 4918) instead of `400 Bad Request`; `400 Bad Request` is now reserved for malformed requests (unparseable JSON, wrong `Content-Type`, route/body mismatch) per RFC 9457
- Field validation failures now return `422 Unprocessable Entity` (RFC 4918) instead of `400 Bad Request`; `400 Bad Request` is now reserved for malformed requests (unparseable JSON, route/body mismatch); unsupported media types return `415 Unsupported Media Type` (RFC 9110 §15.5.16) via the `[Consumes]` attribute. Error responses follow the Problem Details format (RFC 9457).

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ public async Task Post_Players_Nonexistent_Returns201Created()

// Note: the controller's 409 Conflict branch (squad number already exists) is
// unreachable via the HTTP pipeline. The "Create" validation rule set includes
// BeUniqueSquadNumber, which returns a 400 validation error before the
// controller's own duplicate check ever runs. The 409 path is covered by the
// unit test Post_Players_Existing_Returns409Conflict, where validation is mocked
// to pass so the controller logic can be exercised in isolation.
// BeUniqueSquadNumber, which returns a 422 validation error (Unprocessable Entity)
// before the controller's own duplicate check ever runs. The 409 path is covered
// by the unit test Post_Players_Existing_Returns409Conflict, where validation is
// mocked to pass so the controller logic can be exercised in isolation.

[Fact]
[Trait("Category", "Integration")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public async Task Post_Players_ValidationError_Returns422UnprocessableEntity()
);
var httpResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
httpResult.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
var problemDetails = httpResult
.ProblemDetails.Should()
.BeOfType<HttpValidationProblemDetails>()
.Subject;
problemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails
.Errors.Should()
.ContainKey("SquadNumber")
.WhoseValue.Should()
.Contain("SquadNumber must be greater than 0.");
}

[Fact]
Expand Down Expand Up @@ -341,6 +351,16 @@ public async Task Put_PlayerBySquadNumber_ValidationError_Returns422Unprocessabl
);
var httpResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
httpResult.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
var problemDetails = httpResult
.ProblemDetails.Should()
.BeOfType<HttpValidationProblemDetails>()
.Subject;
problemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails
.Errors.Should()
.ContainKey("SquadNumber")
.WhoseValue.Should()
.Contain("SquadNumber must be greater than 0.");
}

[Fact]
Expand Down
Loading