views:

831

answers:

6

I want to use dynamic mocks when testing a Silverlight application. I have tried Moq and Rhino but these frameworks assemblies cannot be added to a silverlight project as they are incompatible with the silverlight runtime.

Is there an existing silverlight mock framework (or patch for moq) that will allow me to use mock objects in a silverlight runtime?

A: 

Yes and no :-)

I believe Moq is being enabled to run inside of Silverlight at the moment, unable of the status though. As far as I know there are no mocking frameworks that will run under Silverlight.

However you can run Silverlight code inside of Visual Studio and unit test it there. Not quite the same thing but it does offer some interesting capabilities like using existing tools. Check this blog post by Roy Osherove for details.

Maurice
Thanks for your help Maurice, I'm using silverlight test framework and it's quite nice. I guess I'm just going to have to wait for dynamic mocks to be available in the Silverlight runtime.
Myrtleoturtle
A: 

Moq has been ported to run under Silverlight. It will be released with the next version of Moq (which is coming very soon). Or you can just pull the trunk from code.google.com/p/moq and compile it yourself...

Jason Jarrett
A: 

There is a working version of Rhino Mocks delivered by Ayende Rahien, I've tried this out over the last week and it works correctly in the Silverlight runtime. Great to see that mock objects are now available in Silverlight.

Myrtleoturtle
+2  A: 

The latest release of Moq has a fully supported silverlight version as well...

Jason Jarrett
+1  A: 

There is an open source framework called SilverUnit that sits on top of Typemock., it is a good tool for mocking Silverlight

A: 

HI, i would recommend the JostMock Framework from telerik. It works nice with the Silverlight Unit Test Framework (Toolkit April 2010).

Unfortunately it´s no Open Source but there´s a trial...

Michi