BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

Moq 3.0 Released

by Al Tenhundfeld on Mar 10, 2009 |

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.

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

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT