Mocking with Moq and NUnit

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 is a mocking library for .NET that makes it easy to create mock objects and make writing unit tests easier.
Course info
Rating
(32)
Level
Intermediate
Updated
Feb 22, 2019
Duration
1h 53m
Table of contents
Course Overview
Getting Started with Moq
Configuring Mock Method Return Values
Working with Mock Properties
Checking That Mock Methods and Properties Are Used
Using Partial Mocks and Advanced Mocking Techniques
Description
Course info
Rating
(32)
Level
Intermediate
Updated
Feb 22, 2019
Duration
1h 53m
Description

Writing effective unit tests can be tricky when dependencies between classes make it hard to separate what's being tested from the rest of the system. In this course, Mocking with Moq and NUnit, you will gain the ability to easily isolate parts of your codebase for testing purposes. First, you will learn how to substitute real dependencies for mock objects. Next, you will discover how to configure mocked methods, properties, exceptions, and events. Finally, you will explore how to create behavior-based tests and also how to create partial mocks from existing classes. When you’re finished with this course, you will have the skills and knowledge of mocking with Moq needed to create automated tests that use 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
More courses by Jason Roberts
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone. My name's Jason Roberts. Welcome to my course, Mocking with Moq and NUnit. I'm a freelance developer and author. In this course you're going to learn how to use the Moq mocking library to make it easier to test parts of your code base in isolation. Some of the major topics that we'll cover in this course include how to set up and create mock objects, set up mock methods and properties to return the values you want, check that the expected members are invoked on mock objects using behavior- based tests, how to deal with mock events and exceptions, and how to use partial mocks to help test difficult things, such as code that uses DateTime.Now. By the end of this course you'll understand how to use Moq to isolate the code you want to test from the rest of the system. Before beginning the course it's recommended that you have a basic understanding of C#, and if you aren't familiar with the NUnit testing framework you should go and watch the Introduction to .NET Testing with NUnit 3 course first. I hope you'll join me on this journey with the Mocking with Moq and NUnit course at Pluralsight.