You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add more context to sample
* Update date for test-min-api.md
Just updated the ms.date metadata.
---------
Co-authored-by: Wade Pickett <[email protected]>
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/minimal-apis/test-min-api.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Test Minimal API apps
3
3
author: wadepickett
4
4
description: Unit and integration tests in Minimal API apps
5
5
ms.author: wpickett
6
-
ms.date: 05/31/2024
6
+
ms.date: 09/15/2025
7
7
monikerRange: '>= aspnetcore-7.0'
8
8
uid: fundamentals/minimal-apis/test-min-api
9
9
---
@@ -20,15 +20,17 @@ The [sample code on GitHub](https://github.com/dotnet/AspNetCore.Docs.Samples/tr
20
20
21
21
<aname="iit7"></a>
22
22
23
-
## IResult implementation types
23
+
## Unit test IResult implementation types
24
+
25
+
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).
24
26
25
27
Public <xref:Microsoft.AspNetCore.Http.IResult> implementation types in the <xref:Microsoft.AspNetCore.Http.HttpResults?displayProperty=fullName> namespace can be used to unit test minimal route handlers when using named methods instead of lambdas.
26
28
27
-
The following code uses the [`NotFound<TValue>`](/dotnet/api/microsoft.aspnetcore.http.httpresults.notfound-1) class:
29
+
The following code uses the <xref:Microsoft.AspNetCore.Http.HttpResults.NotFound%601> class:
0 commit comments