About the author

Brian Keating is a developer addicted to Microsoft Technologies.

Month List

RecentComments

Comment RSS

Moq

clock November 18, 2010 21:48 by author Brian Keating |

How many of you create your own mocks? I've recently been using Mocq and I give it the thumbs up :-)

 Note it's using .net 3.5; time for an upgrade? I can't stress enough how much I love linq, today worked on a problem for a client that were using 3.0; it's a true saying " you never miss the water till the well runs dry" ! 

I wonder however I ever lived without it. 

 Anyway:

Moq (pronounced "Mock-you" or just "Mock") is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 (i.e. Linq expression trees) and C# 3.0 features (i.e. lambda expressions) that make it the most productive, type-safe and refactoring-friendly mocking library available. And it supports mocking interfaces as well as classes. Its API is extremely simple and straightforward, and doesn't require any prior knowledge or experience with mocking concepts.

 

var mock = new Mock<ILoveThisFramework>(); 
 
// WOW! No record/replay weirdness?! :) 
mock
.Setup(framework => framework.DownloadExists("2.0.0.0")) 
   
.Returns(true) 
   
.AtMostOnce(); 
 
// Hand mock.Object as a collaborator and exercise it,  
// like calling methods on it... 
ILoveThisFramework lovable = mock.Object; 
bool download = lovable.DownloadExists("2.0.0.0"); 
 
// Verify that the given method was indeed called with the expected value 
mock
.Verify(framework => framework.DownloadExists("2.0.0.0"));




Silverlight extra day of PDC...

clock November 17, 2010 16:34 by author Brian Keating |

Register now!

 

Learn about the future of Silverlight from Corporate Vice President, Scott Guthrie and other experts, direct from Microsoft’s HQ.

http://www.silverlight.net/news/events/firestarter/

 

If you are a INETA User Group Leader or INETA Country Lead er, please help us to deliver this message and spread it. Thanks!