From 513f865610bdc8b323bf1661e9dfc652580dac7e Mon Sep 17 00:00:00 2001 From: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com> Date: Mon, 15 Sep 2025 19:28:15 +0200 Subject: [PATCH 1/2] add more context to sample --- aspnetcore/fundamentals/minimal-apis/test-min-api.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/aspnetcore/fundamentals/minimal-apis/test-min-api.md b/aspnetcore/fundamentals/minimal-apis/test-min-api.md index bce516f6589e..9c2870e66075 100644 --- a/aspnetcore/fundamentals/minimal-apis/test-min-api.md +++ b/aspnetcore/fundamentals/minimal-apis/test-min-api.md @@ -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"::: From 3af7efd1fc9e64d409d4bdf15a115cefc4c75ffc Mon Sep 17 00:00:00 2001 From: Wade Pickett Date: Mon, 15 Sep 2025 14:54:50 -0700 Subject: [PATCH 2/2] Update date for test-min-api.md Just updated the ms.date metadata. --- aspnetcore/fundamentals/minimal-apis/test-min-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/fundamentals/minimal-apis/test-min-api.md b/aspnetcore/fundamentals/minimal-apis/test-min-api.md index 9c2870e66075..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 ---