
Support me on Patreon to access the source code: https://www.patreon.com/milanjovanovic
In this video, I’m going to show you how to unit test your CQRS command handlers. Unit testing command handlers is very easy since most of the dependencies will be injected as interfaces. We will use Moq to provide mocks while unit testing and use FluentAssertion to verify that our command handlers behaved as expected.
Join my weekly .NET newsletter:
https://www.milanjovanovic.tech
Read my Blog here:
https://www.milanjovanovic.tech/blog
Subscribe for more:
https://www.youtube.com/c/MilanJovanovicTech?sub_confirmation1
Chapters
0:00 What are we writing tests for?
1:11 Writing the first unit test
3:08 Accessing internal members in unit tests
4:25 Mocking dependencies with Moq
6:03 Writing assertions with FluentAssertions
7:33 Setting up mock methods
9:00 Writing the second unit test
10:08 Writing our third unit test
12:11 Writing our fourth unit test
Take the opportunity to connect and share this video with your friends and family if you find it useful.
No Comments