diff --git a/aspnetcore/fundamentals/minimal-apis/test-min-api.md b/aspnetcore/fundamentals/minimal-apis/test-min-api.md index c8c34208ed..b5ac22e9b7 100644 --- a/aspnetcore/fundamentals/minimal-apis/test-min-api.md +++ b/aspnetcore/fundamentals/minimal-apis/test-min-api.md @@ -15,9 +15,11 @@ By [Fiyaz Bin Hasan](https://github.com/fiyazbinhasan), and [Rick Anderson](http The [sample code on GitHub](https://github.com/dotnet/AspNetCore.Docs.Samples/tree/main/fundamentals/minimal-apis/samples/MinApiTestsSample) provides an example of unit and integration tests on a Minimal API app. + + ## IResult implementation types -Public implementation types in the namespace can be used to unit test your minimal route handlers when using named methods instead of lambdas. +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 [`Ok`](/dotnet/api/microsoft.aspnetcore.http.httpresults.ok-1) class: diff --git a/aspnetcore/release-notes/aspnetcore-7.0.md b/aspnetcore/release-notes/aspnetcore-7.0.md index 6e29b26809..df844d0691 100644 --- a/aspnetcore/release-notes/aspnetcore-7.0.md +++ b/aspnetcore/release-notes/aspnetcore-7.0.md @@ -130,6 +130,16 @@ In .NET 7 the types implementing `IResult` are public, allowing for type asserti [!code-csharp[](~/fundamentals/minimal-apis/misc-samples/typedResults/TypedResultsApiWithTest/Test/WeatherApiTest.cs?name=snippet_1&highlight=7-8)] +### Improved unit testability for minimal route handlers + + implementation types are now publicly available in the namespace. The `IResult` implementation types can be used to unit test minimal route handlers when using named methods instead of lambdas. + +The following code uses the [`Ok`](/dotnet/api/microsoft.aspnetcore.http.httpresults.ok-1) class: + +:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/minimal-apis/samples/MinApiTestsSample/UnitTests/TodoInMemoryTests.cs" id="snippet_" highlight="18"::: + +For more information, see [`IResult` implementation types](xref:fundamentals/minimal-apis/test-min-api#iit7). + ### OpenAPI improvements for minimal APIs