views:

66

answers:

3

To preface this, I love Moq. I wish I could use it in .NET 3.0. Sadly, however, I cannot, but I would still like to use mocks for unit testing purposes. Also, I've used Rhino before, but I absolutely hate it. To be a little more descriptive, though, it's because the interface feels clunky and unintuitive--which can be dealt with--and the documentation is either horrible or non-existent--which can't.

The essence of my question is whether there are other decently-documented, intuitive, fluent-interface frameworks out there for C#2.0/.NET3.0, or whether I'm stuck banging my head against Rhino in the absence of Moq.

+1  A: 

Have you looked at this question? what-c-mocking-framework-to-use

Christopherous 5000
I have not! I typed in a couple different rewordings of my question to see what came up as I was posting this, but this one didn't appear. I'll take a look.
bwerks
A: 

NUnit has mocking available, so if you're already testing with that, then you should be good to go already. Just include NUnit.Mocks.

It doesn't fulfill your fluent-interface desire though.

SnOrfus
+1  A: 

I personally distinguish three kinds of mocking frameworks(in order of emergence):

  1. Arrange-Act-Assert (AAA) using string method names ala NMock2/NUnit Mocks. Pretty easy to get going but is not strongly typed. If method/property is renamed then the test will fail at runtime.

  2. Record-and-replay ala Rhino Mocks. I totally agree with you, the syntax sucks and I hate using it. It is fully strongly typed so when you refactor a method, the test stays up to date.

  3. AAA using lambdas and expressions. These include MOQ, Latest AAA releases of Rhino Mocks and Typemock Isolator. By far the best syntax, but requires .NET 3.5.

If .NET 3.5 is unavailable, I am afraid that you have to pick the least evil - horrible Rhino Mocks syntax or late binding to method/property names.

PS. Microsoft has its own isolation framework called Moles. I haven't checked it out myself, but it's supposed to be fairly powerful (i.e. mocking static methods, non-public methods etc). Check it out here.

Igor Zevaka
Yeah, I've seen a little about Moles, and it looks lovely; unfortunately it's a full version even more removed from my current project's technology foundation than Moq is. I've you've never seen a grown man cry, I can hook up my webcam.
bwerks
Sadly, I've been forced into Rhino for type-safety reasons. Maybe one day this project will upgrade to something better than 2005 and Moq will become an option.
bwerks