0
votes

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?

1

1 Answers

0
votes

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