Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Isolation framework for testing for Mono

Having read good things about Moles I'd like to add an isolation framework to our set of tools for writing unit tests.

Our application runs under Mono as it is deployed on both Linux and Windows and I cannot seem to find a framework that supports Mono.

I've seen some articles about manipulating assemblies using Cecil but I'm struggling to find anything we could realistically use.

like image 881
sebjsmith Avatar asked Oct 09 '22 02:10

sebjsmith


1 Answers

Looks like Moles works using the JIT, so I'd expect it to be very very tied to microsoft's implementation.

I've had a fantastic amount of success using Moq on mono, With a very small amount of effort it is possible to create a proxy instance of almost any class and intercept nearly all method calls. The latest binary version of Moq works very well on mono for me.

using Moq;

var mock = new Mock<MyClass> { CallBase = true };
mock.Setup( x => x.MyMethod() ).Returns ( 1 );

After using Moq to setup things I generally prefer to use NUnit but you can use any other test framework.

like image 71
IanNorton Avatar answered Oct 13 '22 12:10

IanNorton