Writing unit tests is hard when dependencies between classes make it tough to separate what's being tested from the rest of the system. Moq, the most popular mocking library for .NET, makes it easy to create mock dependencies to make testing easier.
Writing unit tests can be difficult, time-consuming, and slow when you can't isolate the classes you want to test from the rest of the system. In this course, Mocking with Moq and xUnit, you'll learn how to create mocks and use them as dependencies to the classes you want to test. First, you'll discover how to configure mocked methods and properties to return specific values. Next, you'll learn how to perform behavior/interaction testing to check your classes are interacting correctly with their dependencies. Finally, you'll explore how to setup mock exceptions, mock events, and use additional mocking techniques. When you're finished with this course, you'll have the necessary knowledge to use Moq to unit test your classes in isolation by creating and using mock objects.
Course Overview Hi everyone. My name's Jason Roberts, and welcome to my course, Mocking with Moq and xUnit. I'm a freelance developer and author. Writing unit tests can be difficult, time consuming, and slow when you can't isolate the classes you want to test from the rest of the system. In this course, we're going to use the Moq mocking library to create fake dependencies and use them to isolate parts of the code base for testing purposes. Some of the major topics that we'll cover include how to configure mocked methods to return specific values, how to set up and work with mocked properties, how to check your code is interacting correctly with its dependencies, and some more advanced techniques such as throwing events and throwing exceptions from mock objects. By the end of this course, you'll know how to use Moq to create, configure, and use mock objects to isolate parts of your code base for testing. Before beginning the course, you should be familiar with basic C# syntax. From here, you should feel comfortable diving into some additional testing tools with courses on approval tests, fluent assertions, and creating automated browser tests with Selenium and C#. I hope you'll join me on this journey to learn mocking with the Mocking with Moq and xUnit course, at Pluralsight.