NovaJoe
NovaJoe

Reputation: 4625

Are there any mocking frameworks for Mono??? I'm floored that I can't seem to find one

I'm just looking for a definitive answer on this: are there any mocking frameworks that work with Mono, like Moq or RhinoMocks??? Yes, I realize I can do manual mocks, but I'm talking about something with a nice API...like Moq or RhinoMocks. I'm working with MonoTouch specifically, but I'm surprised I haven't even been able to find any mocking frameworks for straight Mono either.

From what I've read, it seems that one of the reasons why there's no mocking framework for MonoTouch is because most of them use Reflection.Emit, which will of course not pass Apple's static analysis for AppStore submission.

BUT, what about non-AppStore apps? Lots of enterprise apps are distributed outside of the AppStore and so are not subject to the static analysis. AND it's very common to see mocking frameworks used in enterprise apps.

So, why don't we see mocking frameworks being used more frequently with MonoTouch apps?

Upvotes: 4

Views: 718

Answers (2)

Ash
Ash

Reputation: 5087

I've found that Simple.Mocking works out of the box with Mono. It isn't quite as neat as some of the other mocking frameworks out there but it does work!

Upvotes: 2

NovaJoe
NovaJoe

Reputation: 4625

Well, I found that the Moq source from GitHub CAN be compiled for Mono. But you also need Castle.Core.

However, you try to build Castle.Core with Mono 2.10.x (2.10.11 at the time of this writing), you'll get a compile error (CS0314) about generic type constraints in PriorityBehaviorExtensions.cs. This is a bug in the 2.10.x builds of Mono.

In order to build Castle.Core, I had to build with Mono 3.0.10. Once you have that dependency satisfied, you can use Castle.Core to build Moq.

I still have to do some testing to make sure all is well. Just wanted to get this all written up before I head out the door. Hope this helps someone.

Thanks to the author of Moq (Daniel Cazzulino) for pointing me in the right direction.

EDIT: This is NOT working for me. I was able to build the DLLs just fine, but they were targeting the wrong framework. The problem is that I can't seem to build the Castle.Core library targeting MonoTouch because some of the functionality of .NET that Castle.Core takes advantage of is simply not available in Mono. SO, without being able to build Castle.Core for MonoTouch, I also cannot build Moq or even RhinoMocks for MonoTouch either.

Upvotes: 3

Related Questions