Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax Comparison between Moq and Rhino mocks

My company is trying to decide if we are going to standardize on Moq, Rhino Mocks or MS Moles and Stubs.

I know Rhino Mocks and Moles and Stubs fairly well. But I am unfamiliar with Moq. How does the syntax work? Does it support Arrange Act Assert (AAA) like Rhino Mocks (I hear they created it, but I am not sure). Does it have strong typing?

Basically, I am leaning towards Rhino Mocks (using Moles where needed). But I don't want to do that just because I am familiar with Rhino Mocks. If Moq is in fact better or (even more important) easier to use, then I want to learn it and pick that one.

So, any one out there that has used both and feels like giving me a syntax comparison?

like image 902
Vaccano Avatar asked Sep 14 '10 20:09

Vaccano


People also ask

What is mock in MOQ?

A mock object is an object that can act as a real object but can be controlled in test code. Moq is a library that allows us to create mock objects in test code.

Which is a valid mock type using Rhino?

Mock OptionsStrict Mock. A strict mock requires you to provide alternate implementations for each method/property that is used on the mock. If any methods/properties are used which you have not provided implementations for, an exception will be thrown. Dynamic Mock.


2 Answers

I've done a multi-part blog series on the differences between a number of mocking frameworks. Feel free to check it out at http://www.richard-banks.org/2010/07/mocking-comparison-part-1-basics.html

like image 190
Richard Banks Avatar answered Sep 18 '22 11:09

Richard Banks


Have you looked at http://code.google.com/p/moq/wiki/QuickStart ?

Moq supports AAA and strong typing (via use of lambdas)

like image 40
marcind Avatar answered Sep 18 '22 11:09

marcind