Skip to content

Basic examples of mocking in .Net with manual mocks and Moq library

License

Notifications You must be signed in to change notification settings

Ermlab/how-to-start-mocking-with-moq

Repository files navigation

How to start mocking with Moq

Description

This project contains basics of mocking in .Net. We show how to create manual mocks and how to use Moq library. Code was used as examples for a post on our blog.

In project we show:

  • How to use manual mocks
  • How to write simple test with basic Moq usage
  • How to setup method with Moq to throw an exception
  • How to check with Moq if mocked method was called and how many times
  • How to setup method with Moq to return different values on each call
  • How to setup a method with Moq to raise an event or how to raise an event by hand

How to run project

You will need Visual Studio 2017 with installed NUnit Runner extension.

Used technology

In this project we used:

  • C#
  • NUnit
  • Moq

About

Basic examples of mocking in .Net with manual mocks and Moq library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages