What are the capabilities of Moq and Rhino.mocks?
Asked Answered
D

5

44

I cannot find a specific feature-by-feature comparison of Moq and Rhino. All the questions are "which do you like better and why", or "here's how you do a simple mock in rhino and how it's done in moq".

I cannot find a deep comparison anywhere. I'm aware of the syntax differences, I'm not looking for answers about that. I am looking for a capability comparison. For example:

  • Rhino has Expect.On() for threaded mocking. Can Moq do this?

  • What about Multi-mocking (implementing multiple interfaces with one mock). Can Moq do this?

  • I believe Moq can now mock Protected members. Can Rhino do this?

Edit: I ended up looking at some of the other .Net frameworks as well.

Demolish answered 27/3, 2009 at 17:42 Comment(2)
- Check here for the moq features - Check here for the Rhino Mocks featuresCounterchange
see also #643120Stucker
D
88

Thanks to those that responded over the last few weeks. I ended up writing a blog post about my findings, since I had to do so much digging that it seemed like I might as well summarize them in the hopes of helping others. The chart I posted organizes my findings:

alt text

One caveat, which I touched on in the blog post, is that the chart is useful for checking the capabilities, but the real advantages to most frameworks are their unique features. I chose Moq in the end because of the easy to use API. Also, all the information is subject to errors and change - if you disagree with something on the chart, please post a comment.

Demolish answered 27/4, 2009 at 17:5 Comment(4)
I updated the chart slightly. There may be a couple revisions to it over the next little while, I have some other additional line items that might be added.Demolish
Hey @womp, can you please reupload the chart? The link is redirecting to some Japanese sign ;-)Conferral
@DariuszWoźniak amazingly I was able to find it on an ancient backup of my old website. I've reposted it :) Keep in mind of course that this answer is now 8 years old!Demolish
That is a very useful comparison chart, but since it's from 10 years ago - it might be outdated. For example: Even though I haven't used moq myself yet, it seems that at least in some cases it does support verification of order of method calls: see https://mcmap.net/q/89520/-using-moq-to-verify-calls-are-made-in-the-correct-order and riptutorial.com/moq/example/23018/…Kirov
S
2

I'm not an expert by any means, but I believe the Rhino added some of the Moq syntax so that the learning curve has been reduced to what you'd expect with MoQ. I worked with both with testing and some of the syntax was almost identical. I was initially going to go with MoQ as it was easier, but then my bud showed me the latest updates and how similar they were. Just letting ya know.

Skunk answered 27/3, 2009 at 18:17 Comment(2)
I actually find that this is one of the things that makes Rhino harder. Almost all the documentation is for the older syntaxes, so you end up mixing them up when looking at the examples, leading to all kinds of weird errors :/Demolish
Agreed.It seems like they've tried to do certain things multiple ways without removing the "old" way of doing it. I suppose it's for compatibility. I honestly have a lot better understanding of MoQ just because it doesn't try to diff a Mock or a Fake and no funky syntax. MoQ's pretty nice with thatSkunk
G
1

Rhino has GetArgumentsForCallsMadeOn() which IMO makes it easier to verify arguments in some cases.

Gayomart answered 11/4, 2009 at 17:2 Comment(0)
K
0

Just for completeness I will note that there is now NMock3 on CodePlex. It has easy migration from NMock2, just replace the reference to NMock2.dll with a reference to NMock3.dll. It adds type safety and support for refactoring.

Kipton answered 20/1, 2011 at 20:17 Comment(0)
G
-1

I might add "Behavior Verification" into these. That seems to be Moq's biggest limitation, which Rhino (not sure about others) has no problem with.

Graycegrayheaded answered 12/6, 2009 at 20:57 Comment(1)
What is limited about behaviour verification in Moq? I haven't run into any limitations yet. It has Verify() and VerifyAll(), and you can set any Setup() call to be Verifiable regardless of return value.Demolish

© 2022 - 2024 — McMap. All rights reserved.