Skip to content

Use WebApplication in unit tests#18

Merged
abdebek merged 5 commits intoabdebek:mainfrom
erwinkramer:main
Jan 24, 2026
Merged

Use WebApplication in unit tests#18
abdebek merged 5 commits intoabdebek:mainfrom
erwinkramer:main

Conversation

@erwinkramer
Copy link
Contributor

This pull request refactors the test server setup in several test classes to use the newer WebApplication and minimal API patterns introduced in ASP.NET Core, replacing the older HostBuilder and IApplicationBuilder approach. This change simplifies server configuration, makes the test code more concise, and aligns it with modern ASP.NET Core best practices.

Test server setup modernization:

  • Replaced usage of HostBuilder and IApplicationBuilder with WebApplication.CreateBuilder() and minimal API endpoint mapping (e.g., app.MapGet, app.MapPost) in TestApiServer, TestOAuthServer, and TestClientCredentialsServer, as well as in integration test helpers. This results in less boilerplate and easier-to-read test server setup. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

Test helper refactoring:

  • Updated test helper methods such as CreateHostAsync in integration tests to use WebApplication and minimal APIs, improving consistency and reducing code duplication. [1] [2] [3]

Type and method signature updates:

  • Changed signatures of private configuration methods to accept WebApplication instead of IApplicationBuilder to match the new server setup approach. [1] [2]

These changes modernize the test infrastructure, making it easier to maintain and extend in the future.

Copy link
Owner

@abdebek abdebek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks!

@abdebek abdebek merged commit 81eabd5 into abdebek:main Jan 24, 2026
1 check passed
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