☄️ Master the Modular Monolith Architecture: https://bit.ly/3SXlzSt
📌 Accelerate your Clean Architecture skills: https://bit.ly/3PupkOJ
🚀 Support me on Patreon to access the source code: / 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/MilanJovano...
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
Watch video Unit Testing CQRS Handlers With Moq, Fluent Assertions, and xUnit online, duration hours minute second in high quality that is uploaded to the channel Milan Jovanović 25 October 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 36,888 times and liked it 1.2 thousand visitors.