Mocking in C# Unit Tests – How to Test Data Access Code and More

Mocking in C# Unit Tests – How to Test Data Access Code and More

HomeIAmTimCoreyMocking in C# Unit Tests – How to Test Data Access Code and More
Mocking in C# Unit Tests – How to Test Data Access Code and More
ChannelPublish DateThumbnail & View CountDownload Video
Channel AvatarPublish Date not found Thumbnail
0 Views
Unit testing is great, but how do you test your data access? You certainly don't want to delete records when testing the delete method, but you definitely want to be sure that the method is configured correctly. This is the kind of problem that stops many developers from creating unit tests. In this video, I'll show you how to overcome these obstacles to write tests that handle working with external dependencies like databases.

Full courses: https://www.iamtimcorey.com/
Source code: https://leadmagnets.app/?ResourceMockingInUnitTests
Patreon: https://patreon.com/IAmTimCorey
Newsletter registration: https://signup.iamtimcorey.com/

Sponsors:
Tuhafeni Angula (Patreon subscriber)

0:00 – Introduction
1:05 – Getting started: demo application code and setup
10:20 – Problems with test methods that manipulate external things (database changes, email senders, etc.)
12:39 – Mockery explained
15:44 – Writing tests with mocking
18:05 – Adding references for testing with MOCK
20:51 – Using statement
22:12 – AutoMock.GetLoose() vs. AutoMock.GetStrict();
23:30 – Using AutoMock: Writing the Unit Test with Mocking
35:06 – Refactoring a method that is subject to a unit test
36:03 – Check data: compare two objects
40:19 – Test method that returns void
48:16 – Testing the SQL call change
52:47 – Summary
53:30 – Advice for beginners
55:15 – What should not be tested and why
58:24 – Summary
59:27 – Learning steps
1:01:42 – Concluding remarks

Please take the opportunity to connect with your friends and family and share this video with them if you find it useful.