Moq is a popular mocking library for .NET. Version 3.0 RTM has been released and is available for download.

Moq's popularity has grown as mocking has become mainstream in .NET, in part because Moq is designed for developers who are new to mocking or may be writing their own custom mock objects. Moq does not use the classic record/reply idiom and instead lets testers set behavioral expectations, often through lambda expressions, and intercepts mock object calls by utilizing Castle DynamicProxy.

Moq 3.0 represents a major new release, with the following notable changes:

Silverlight Support

A separate binary is available that is fully compatible with Silverlight. New simplified event raising syntax

Example: mock.Raise(foo => foo.MyEvent += null, new MyArgs(...)); Support for custom event signatures (not compatible with EventHandler)

Example: mock.Raise(foo => foo.MyEvent += null, arg1, arg2, arg3); Improved property setter behavior

Example: mock.VerifySet(foo => foo.Value = "foo"); Additional sample application code

ASP.NET MVC application also updated to work with latest version Better integration with Pex Previously, Pex would spend effort analyzing the Moq library code, trying to understand the internals of Moq framework. In 3.0 release, Pex attributes have used to shut down the Pex monitoring for certain areas of Moq which aren't relevant to the code under test.

To help get started with Moq, browse the convenient API documentation or find one of the many getting started guides, like Justin Etheredge's (C# MVP) recent series on Beginning Mocking with Moq 3.