Mocking in .NET Core Unit Tests with Moq: Getting Started

Moq is the most popular mocking framework for .NET. This course will teach you how to isolate parts of your codebase for easier testing by creating and configuring test-time-only mock versions of dependencies.
Course info
Rating
(75)
Level
Intermediate
Updated
Dec 1, 2017
Duration
1h 57m
Table of contents
Course Overview
Getting Started with Mocking and Moq
Mocking Method Calls
Mocking Properties
Implementing Behavior Verification Tests
Using Additional Mocking Techniques
Description
Course info
Rating
(75)
Level
Intermediate
Updated
Dec 1, 2017
Duration
1h 57m
Description

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 in .NET Core Unit Tests with Moq: Getting Started, 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 cover how to perform behavior/interaction testing. Finally, you'll explore how to setup mocked exceptions and events. 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.

About the author
About the author

With over 15 years experience, Jason Roberts is a Microsoft .NET MVP, freelance developer, and author.

More from the author
Working with Nulls in C#
Intermediate
2h 9m
Aug 19, 2019
Mocking with Moq and NUnit
Intermediate
1h 53m
Feb 22, 2019
More courses by Jason Roberts
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone, my name is Jason Roberts. Welcome to my course, Mocking in. NET Core Unit Tests with Moq: Getting Started. I'm a Microsoft MVP, freelance developer and author. In this course we're going to learn how to get started writing unit tests that can isolate only those parts of the application you actually want to test by creating and using mock objects. Some of the major topics that we'll cover on this course include how to create mocks and use them as dependencies to the classes you're testing, how to configure the return values of mock methods and properties, how to verify that your classes are interacting correctly with mocks, and also how to mock exceptions and events. By the end of this course you'll understand how mocks help to isolate parts of the code base to make testing subsets of the application easier, how to create and configure Moq mock objects, and how to use them as test time dependencies for the classes you're testing. Before beginning the course it's recommended that you have at least a basic understanding of C#. I hope you'll join me on this journey with the Mocking in. NET Core Unit Tests with Moq: Getting Started course at Pluralsight.