Coding Shorts: Should You Be Using TypedResults in ASP.NET Core APIs?

preview_player
Показать описание
*** SORRY ABOUT THE MONO AUDIO - YOUTUBE WONT LET ME FIX WITHOUT DELETING THE VIDEO ***

Unit testing APIs in .NET has been a problem for a while. While you can just decide to only do integration testing, it's nice that .NET 7 includes a new feature to make it easier. Let's dig into TypedResults together.

You can hire me too! You can reach me at my new website:

The source code for this is at:

If you like this video, you might like other videos in my Instructional Videos:
Рекомендации по теме
Комментарии
Автор

I have not used Results/TypedResults for unit testing but I like that the Getxxx signature type is visible and the compiler gives errors if there is not a match in the returned values. It also helps generate the OpenAPI spec automatically saving me effort on specifying the return values manually.

finnurhrafn
Автор

TypedResults appears to be an excellent feature, particularly for unit testing. Our team has found testing the output of controllers to be quite challenging, as it often involves jumping through hoops just to access the actual result value. We eventually chose to focus our efforts on unit testing the services and forgo the controllers. From our perspective, the controllers were merely returning the results of the service call. So, we had to ask ourselves: were we genuinely testing our own code, or were we just testing Microsoft's controller code?

djglxxii
Автор

I am interested about your People API which registers itself. Do you have a video about that? It would be interesting to find out more. Thank you.

foonlam
Автор

I love your videos, but I would really appreciate if the voice track was in mono, because this left-heavy audio is really annoying to listen in headphones 😿

neurocat
Автор

The unit test are more looking like integration, agree? I have not noticed you mocked anything...

nixnemo
Автор

Shawn, your voice is only on the left-channel. The intro music was both channels, so I assume there's an issue with the mic. Might be as simple as an analog mic not being fully plugged-in. Honestly, it makes it uncomfortable to listen to, especially when your "talking head" is on the right.

elerius