Unit testing in C# .NET with MSTest & Moq

2 months ago
4

I show you how to unit test simple scenario's and more advanced scenario's using Moq to mock complex dependencies like Entity Framework Core's DbContext.

Once you get the hang of it, testing is a blast :)! Enjoy!

The source code can be found here: https://www.patreon.com/posts/unit-testing-in-88459377?utm_medium=clipboard_copy&utm_source=copyLink&utm_campaign=postshare_creator&utm_content=join_link

If you found this video helpful, like & subscribe, that means a lot to me!

00:00 Intro
01:50 Why to test?
03:18 Demo setup
04:20 New test project
06:20 Move business logic
08:35 New unit test
11:16 Mock dependencies
14:53 Arrange Act Assert
18:30 Happy / Unhappy paths
22:30 Test with database
25:20 InMemoryDatabase
29:10 Why Mocked Database
31:45 Source code
33:36 Understand Mocking
38:40 MockQueryable
45:20 Finalize demo
47:36 Recap
50:03 Testing IMO
52:48 Outro

#unittesting #testing #dotnet #csharp #webapi #serilog #logging #monitoring #api #webdevelopment #fullstack #fullstacksoftwareengineering #backend #docker #azure #containerization #devops #cloud #microsoft #linux #entityframework #identityframework #mssqlserver #mssql #cleanarchitecture #authentication #api #development #local #web #fullstack #webdevelopment #authorization #jwt #bearer #cqrs #mediatr #webapi #cors #http #stateless #webscraping #workers #migration #mstest #mock #mocktest

Loading comments...