diff --git a/aspnetcore/fundamentals/minimal-apis/test-min-api.md b/aspnetcore/fundamentals/minimal-apis/test-min-api.md index bce516f6589e..f181be4e66c2 100644 --- a/aspnetcore/fundamentals/minimal-apis/test-min-api.md +++ b/aspnetcore/fundamentals/minimal-apis/test-min-api.md @@ -3,7 +3,7 @@ title: Test Minimal API apps author: wadepickett description: Unit and integration tests in Minimal API apps ms.author: wpickett -ms.date: 05/31/2024 +ms.date: 09/15/2025 monikerRange: '>= aspnetcore-7.0' uid: fundamentals/minimal-apis/test-min-api --- @@ -20,15 +20,17 @@ The [sample code on GitHub](https://github.com/dotnet/AspNetCore.Docs.Samples/tr -## IResult implementation types +## Unit test IResult implementation types + +The following example shows how to unit test minimal route handlers that return 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). Public implementation types in the namespace can be used to unit test minimal route handlers when using named methods instead of lambdas. -The following code uses the [`NotFound`](/dotnet/api/microsoft.aspnetcore.http.httpresults.notfound-1) class: +The following code uses the class: :::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/minimal-apis/samples/MinApiTestsSample/UnitTests/TodoInMemoryTests.cs" id="snippet_" highlight="8"::: -The following code uses the [`Ok`](/dotnet/api/microsoft.aspnetcore.http.httpresults.ok-1) class: +The following code uses the class: :::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/minimal-apis/samples/MinApiTestsSample/UnitTests/TodoInMemoryTests.cs" id="snippet_1" highlight="18":::