C# – How to write a simple Silverlight unit test

csilverlighttestingunit testing

I'm looking to create some Silverlight unit tests. I've started by downloading the Silverlight Toolkit and looking at the unit tests there which are all built on the Silverlight Unit Testing Framework.

However it seems that the test class structure is quite complex in the source and I don't want to re-write the test classes defined in that package (e.g. ControlTest->FrameworkElementTest->TestBase->SilverlightTest inheritance chain is defined and only the last class is all defined in the Silverlight Toolkit).

I'm looking for a code sample of the simplest unit test implementation possible with the Silverlight Unit Test Framework (e.g. executing Assert.IsTrue(true)).

Best Answer

I'm surprised Jeff Wilcox didn't link to his own article!

This is the one that I used to set up my tests in Silverlight:

http://www.jeff.wilcox.name/2008/03/silverlight2-unit-testing/#option2

It was originally written for Silverlight 2, but I got it working under 3 with no issues.