What is a Mock object, and how to Setup a method in interfaces and 3rd party libraries using C# and XUnit, and Moq.
Buy me a coffee: https://buymeacoffee.com/foadalavix
Patreon: / foadalaviyoutube
⏱️⏱️VIDEO CHAPTERS⏱️⏱️
00:00 - Intro
00:37 - Understanding the project
02:50 - Mock against interfaces
17:49 - How to Mock Dbontext in a Generic Repository
25:50 - How to Mock Dbontext in a Repository
29:00 - Using Fuent Assertion
31:31 - Mocking HttpClient
🔔 Subscribe for more tips just like this: https://www.youtube.com/@Foad_Alavi?s...
In this tutorial, we'll build a simple mock object representing an HTTP client. We'll then use this mock object to Setup a method that will make a request to a URL. We'll also mock a generic Repository and one specific repository that uses EntityFramework to get data from an SQL database.
This mock tutorial is perfect for beginners who want to learn how to mock objects, HTTP clients, and EF. By the end of this tutorial, you'll have learned how to Setup a method, create a mock object, and mock against interfaces and HTTPClient and EntityFramework. So let's get started!
GitHub Repo: https://github.com/foadalavi/Test-Fou...
All About Testing Playlist: • All About Testing
#testing #csharp #dotnet #mocktest #httpclient