0

I have recently tried using the Silverlight NUnit Project template (the one from Jamie Cansdale found here) for a Silverlight 4 project that uses WCF RIA 1.0. I seem to be close, but I still cannot get it to work.

Here's what I've done

  1. Create project. :)
  2. Change Silverlight version to 4.
  3. Set the WCF RIA Services Link to my WCF RIA project.
  4. Make sure that all of the references (except for mscorlib) are CopyLocal=True.
  5. Try to run the tests.

What happens?

The test fixture setup (which contains only the line "_context = new MyContext();") dies with this exception:

1 test failed: SetUp : System.TypeInitializationException : The type initializer for 'MS.Internal.JoltHelper' threw an exception. ---

Has anyone else been able to use the template to test against WCF RIA projects?

David Moye
  • 701
  • 4
  • 13

1 Answers1

0

The NUnit console doesn't support silverlight. See: http://greenicicleblog.com/2010/04/27/nunit-for-silverlight-updated/ (Search for "Is there a way to run these in nunit-console?")

You can get a Silverlight port of NUinit from google code (from link above) but then you've got to use the Silverlight Test runner as described in the first link above. This is OK for manually running the tests, but not useful in a continuous integration scenario.

The problem is that when the tests run in NUnit console, I believe it runs in the CLR, not the Silverlight runtime.

We have successfully used NUnit and NCover with some Silverlight code, but then it's because the code we were testing was compatible with the full .NET CLR.

This is also a good article that describes how to unit test Silverlight with NUnit: http://chris.59north.com/post/Introduction-to-setting-up-automated-unit-testing-in-Silverlight-with-NUnit.aspx

G. Lombard
  • 3,569
  • 1
  • 29
  • 30
  • So to be clear, I meant to say, I believe because you're using RIA Services, your project requires the Silverlight Runtime, and isn't compatible with the standard .NET CLR, so won't run in NUnit. The last link I posted above should help you in the right direction. – G. Lombard Mar 04 '11 at 15:07
  • This might also be useful to someone: http://weblogs.asp.net/nunitaddin/archive/2008/05/01/silverlight-nunit-projects.aspx – G. Lombard Mar 07 '11 at 13:13
  • I'll check out the link in your last paragraph, but my understanding was that the Silverlight NUnit Project Template that I referenced had been recompiled with the Silverlight libraries and will run Silverlight code. I just can't get it to work with RIA. – David Moye Mar 07 '11 at 16:28