Skip to content

Commit 8fb341b

Browse files
committed
refer to testing docs in favor of inline example
1 parent 6ab28e5 commit 8fb341b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

aspnetcore/fundamentals/minimal-apis/responses.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,7 @@ In order to document this endpoint correctly the extensions method `Produces` is
8484

8585
For more information about describing a response type, see [OpenAPI support in minimal APIs](/aspnet/core/fundamentals/openapi/aspnetcore-openapi#describe-response-types-1).
8686

87-
As mentioned previously, when using `TypedResults`, a conversion is not needed. Consider the following minimal API which returns a `TypedResults` class
88-
89-
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/minimal-apis/samples/MinApiTestsSample/WebMinRouteGroup/TodoEndpointsV1.cs" id="snippet_1":::
90-
91-
The following test checks for the full concrete type:
92-
93-
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/minimal-apis/samples/MinApiTestsSample/UnitTests/TodoInMemoryTests.cs" id="snippet_11" highlight="26":::
87+
For examples on testing result types, see the [Test documentation](/aspnet/core/fundamentals/minimal-apis/test-min-api#unit-test-iresult-implementation-types).
9488

9589
Because all methods on `Results` return `IResult` in their signature, the compiler automatically infers that as the request delegate return type when returning different results from a single endpoint. `TypedResults` requires the use of `Results<T1, TN>` from such delegates.
9690

aspnetcore/fundamentals/minimal-apis/test-min-api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ The following code uses the <xref:Microsoft.AspNetCore.Http.HttpResults.Ok%601>
3434

3535
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/minimal-apis/samples/MinApiTestsSample/UnitTests/TodoInMemoryTests.cs" id="snippet_1" highlight="18":::
3636

37+
In the previous examples, the result is cast to a concrete type because the endpoint under test can return multiple types (a <xref:Microsoft.AspNetCore.Http.HttpResults.NotFound%601> or <xref:Microsoft.AspNetCore.Http.HttpResults.Ok%601>) result.
38+
However, if the endpoint returns a single <xref:Microsoft.AspNetCore.Http.TypedResults> type, then the result is automatically inferred to that type and no casting is required.
39+
40+
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/minimal-apis/samples/MinApiTestsSample/UnitTests/TodoInMemoryTests.cs" id="snippet_11" highlight="26":::
41+
42+
3743
## Additional Resources
3844

3945
* [Basic authentication tests](https://github.com/blowdart/idunno.Authentication/tree/dev/test/idunno.Authentication.Basic.Test) is not a .NET repository but was written by a member of the .NET team. It provides examples of basic authentication testing.

0 commit comments

Comments
 (0)