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)).
A unit test is a type of software test that focuses on components of a software product. The purpose is to ensure that each unit of software code works as expected. A unit can be a function, method, module, object, or other entity in an application's source code.
The idea is to develop a unit test by following these 3 simple steps: Arrange – setup the testing objects and prepare the prerequisites for your test. Act – perform the actual work of the test. Assert – verify the result.
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.
Just for information, Visual Studio 2010 beta 2 has Silverlight unit testing out of the box. Maybe you want to take a look.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With