This is a mirror of official site: http://jasper-net.blogspot.com/

How to create a Unit Testable solution in Silverlight

| Monday, May 10, 2010
A unit test verifies that a function or set of functions "honors its contract" - in other words, that the function(s) under test meet the requirements. Unit tests inspect both black boxes and white boxes.

This article is not about what is unit testing or how to write unit test cases. There are many articles available in the internet. Here is a very good link which you can follow to get the information on Unit testing.

http://www.codeproject.com/KB/cs/autp1.aspx

It is very common among developer to write code in XAML code behind file to achieve the feature but it reduces the testability of the application. This article describes about how to write a code which is highly testable.

I got the idea of this application from Stock Trader Reference application of PRISM framework. The application has two grids. First grid lists all the available stocks. User can select one stock and add it to watch list. Second grid contains the stocks which user wants to watch. User can select a stock from watch list and click on Remove to remove the stock from watch list. User can enter the text in the Search textbox and click on Search button to search the stocks.

Here we wouldn’t concentrate on application and its UI aspect. We would only concentrate on unit testing of the application.

Using the code

The attached zip file contains two visual studio solutions.

UnitTestDemoApp\UnitTestDemo\UnitTestDemo.sln: It is the ideal solution for testing. Almost zero code in XAML code behind.
UnitTestDemoStart\UnitTestDemo\UnitTestDemo.sln: It is very bad solution for testing. Almost has all the code in code behind. Unit testing is not possible for this solution.

Read more: Codeproject

Posted via email from jasper22's posterous

0 comments: