BT

Your opinion matters! Please fill in the InfoQ Survey!

Moq 3.0 Released

| by Al Tenhundfeld Follow 0 Followers on Mar 10, 2009. Estimated reading time: 1 minute |

A note to our readers: As per your request we have developed a set of features that allow you to reduce the noise, while not losing sight of anything that is important. Get email and web notifications by choosing the topics you are interested in.

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.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT