☄️ Master the Modular Monolith Architecture: [ Ссылка ]
📌 Accelerate your Clean Architecture skills: [ Ссылка ]
🚀 Support me on Patreon to access the source code: [ Ссылка ]
In this video, I will show you how to unit-test domain services. Unit testing domain services is easy since most dependencies will be injected as interfaces. We will use NSubstitute to provide mocks while unit testing and use FluentAssertion to verify that our services behaved as expected. I'll also discuss code coverage and why you don't want to focus on that specific metric. Instead, focus on writing high-quality unit tests.
Join my weekly .NET newsletter:
[ Ссылка ]
Read my Blog here:
[ Ссылка ]
Chapters
0:00 What are we going to test?
1:08 Implementing the first test case
4:10 Improving the test class setup
5:50 Implementing the second test case
7:11 Mocking external dependencies with NSubstitute
11:09 Writing the test case for the happy path
12:47 How to verify method calls on your mock with NSubstitute
15:50 Code coverage report - just focus on writing good unit tests
C# Unit Testing Best Practices for Great Code Coverage
Теги
unit testunit testingunit testing cunit testing vs integration testingunit testing command handlersunit testing handlersunit testing cqrs handlersunit testing cqrsunit testing .netunit testing .net 6xunitfluentassertionsmocktestingteststestverifycode coveragecoverage100% coveragecommand handler unit testmoq unit testfluentassertions unit testnsubstitutensubstitute tutorialnsubstitute mocknsubstitute verifynsubstitute test