Skip to content

Rewrite AcceptanceTests to use JSON files and JsonNode.DeepEquals#4

Merged
sander1095 merged 2 commits intofix/minimal-api-openapi-empty-pathsfrom
copilot/refactor-test-setup
Feb 28, 2026
Merged

Rewrite AcceptanceTests to use JSON files and JsonNode.DeepEquals#4
sander1095 merged 2 commits intofix/minimal-api-openapi-empty-pathsfrom
copilot/refactor-test-setup

Conversation

Copy link

Copilot AI commented Feb 28, 2026

Rewrite AcceptanceTests to use JSON files and JsonNode.DeepEquals

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Replace inline parameter-checking assertions with JsonNode.DeepEquals against expected JSON files.

Description

The minimal_api and mixed_api acceptance tests used manual assertions (checking path keys, parameter names, version strings). This is fragile and harder to maintain than comparing against a known-good document.

All three acceptance tests now use the same pattern:

using var stream = File.OpenRead( Path.Combine( AppContext.BaseDirectory, "Content", "v1-minimal.json" ) );
var expected = await JsonNode.ParseAsync( stream, default, default, cancellationToken );
// ...
JsonNode.DeepEquals( actual, expected ).Should().BeTrue();

Changes:

  • AcceptanceTest.cs — replaced inline assertions in minimal_api and mixed_api tests with JsonNode.DeepEquals file comparisons; removed unnecessary AddProblemDetails() from the minimal API test
  • Added Content/v1-minimal.json — expected OpenAPI document for the pure minimal API scenario
  • Added Content/v1-mixed.json — expected OpenAPI document for the controller + minimal API scenario

Note: The existing v1.json was not modified. The controller_should_generate_expected_open_api_document test has a pre-existing failure due to culture-dependent date formatting (1/1/2026 vs 01/01/2026) and line ending differences in v1.json.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Replace manual parameter checks in minimal_api and mixed_api tests
with JsonNode.DeepEquals comparison against expected JSON content files.
Add v1-minimal.json and v1-mixed.json expected output files.

Co-authored-by: sander1095 <7312681+sander1095@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor test code for improved setup using JSON files Rewrite AcceptanceTests to use JSON files and JsonNode.DeepEquals Feb 28, 2026
@sander1095 sander1095 marked this pull request as ready for review February 28, 2026 00:25
@sander1095 sander1095 merged commit dcae03e into fix/minimal-api-openapi-empty-paths Feb 28, 2026
@sander1095
Copy link
Owner

@copilot Please create a new issue at dotnet/aspnet-api-versioning for this culture issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants