Skip to content

Conversation

timdeschryver
Copy link
Contributor

@timdeschryver timdeschryver commented Sep 15, 2025

## IResult implementation types
## Unit test IResult implementation types

The following example shows how to unit test minimal route handlers that return <xref:Microsoft.AspNetCore.Http.IResult> using the [xUnit](https://github.com/xunit/xunit/) testing framework. The external database is replaced with an in-memory database during testing, the implementation of the `MockDb` can be found in the [sample code](https://github.com/dotnet/AspNetCore.Docs.Samples/blob/main/fundamentals/minimal-apis/samples/MinApiTestsSample/UnitTests/Helpers/MockDb.cs).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed a same test in https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/responses?view=aspnetcore-9.0#typedresults-vs-results.
I can also add a note about the use of xUnit and the mockDb at that location.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, Thanks!!!! It could be a separate issue/PR if you like, or not, up to you.

@wadepickett wadepickett self-assigned this Sep 15, 2025
Just updated the ms.date metadata.
Copy link
Contributor

@wadepickett wadepickett left a comment

Choose a reason for hiding this comment

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

Great work @timdeschryver, thanks!!!

@wadepickett wadepickett merged commit 4ca1382 into dotnet:main Sep 16, 2025
3 checks passed
@wadepickett wadepickett added reQUEST Triggers an issue to be imported into Quest and removed reQUEST Triggers an issue to be imported into Quest labels Sep 30, 2025
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.

UUF: Test Min API: Clarify testing framework & prereq
2 participants