Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Moq framework

I plan on using Moq to mock some interfaces in the unit test code I've created. I've already downloaded the latest version of Moq.

My question is how do I install it? Where should I place the Moq.dll?

I've tried searching on the internet, but all I can find are samples of how to use Moq, not how to install it.

like image 963
Anthony Avatar asked Dec 10 '12 08:12

Anthony


People also ask

What is Moq framework?

Moq is a mocking framework for C#/. NET. It is used in unit testing to isolate your class under test from its dependencies and ensure that the proper methods on the dependent objects are being called. For more information on mocking you may want to look at the Wikipedia article on Mock Objects.

What is the latest version of Moq?

4.11. 0 (2019-05-28)

Does Moq support .NET core?

Moq is a library that allows us to create mock objects in test code. It is also available in NuGet. This library also supports . NET Core.


2 Answers

The best way to add reference to Moq framework is installing it from Nuget. Also you still can download Moq.dll and add reference to this library (usually I create folder libs under the solution folder, where I put all third-party libraries, which is not available via Nuget).

BTW Another option to install package from Nuget - right click on project references and select Manage Nuget packages.... Then search online for Moq and install it. See why use Nuget over installing libraries directly on my machine

like image 75
Sergey Berezovskiy Avatar answered Sep 17 '22 15:09

Sergey Berezovskiy


There's no need to install it. Just add a reference to the moq.dll in your project.

But of course you can use gacutil to register the library in your global assembly cache.

c:\path> gacutil /i Moq.dll

like image 40
sloth Avatar answered Sep 17 '22 15:09

sloth