Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rhino Mocks & Compact Framework

I've been experimenting with Rhino Mocks for unit testing my .Net Compact Framework application, and have hit a problem. I can get a basic unit test using Rhino Mocks built, but every time I run the test that has the Rhino Mocks code in it, the test fails because it can't find the Rhino Mocks assembly.

System.TypeLoadException: Could not load type 'Rhino.Mocks.MockRepository' from assembly 'Rhino.Mocks...

I've copied the rhino mocks dll to various places on the device (my app folder, and the SmartDeviceTest folder that gets created) but it still can't seem to find it.

Has anyone used rhino mocks with the compact framework and can point me in the right direction? Or failing that, can anyone suggest a mocking framework that does integrate and work with compact framework?

Thanks

Matt

like image 872
Matt Avatar asked Jun 17 '09 00:06

Matt


2 Answers

My bet is that it can't find a dependency. IIRC, Rhino uses a lot of the CompilerServices and Reflection.Emit pieces which simply don't exist in the CF, so it's probably puking when trying to generate the mocks. I've not seen any mocking framework that works with the CF, and I've done quite a bit of looking (and trying to port).

like image 149
ctacke Avatar answered Sep 28 '22 05:09

ctacke


I wrote a blog post on just this a few months ago: http://elegantcode.com/2009/04/29/unit-testingmocking-on-net-cf/

Anyway, RhinoMocks, Moq, and TypeMock do not work on .netcf. Stubs from PEX (a Microsoft Research project) can work in theory, but is not there yet.

The key is to make stub classes instead of Mock classes (google search "Mocks are not Stubs")

like image 32
Chris Brandsma Avatar answered Sep 28 '22 06:09

Chris Brandsma