views:

149

answers:

2

I download command behavior from web and have implemented in my silverlight project. Now I am trying to figure out how to unit test ICommand properties. I know lots of people are working on this, so if you have a good simple example of unit testing ICommand, please let me know.

Thanks Dev

A: 

You downloaded an ICommand implementation from the web? And you want to test it?

I recommend downloading prism and taking a look at their implementation of ICommand. They also have plenty of unit tests in the Reference Implementation (RI).

However, usually we don't test the ICommand implementations very heavily. They either work or they don't. The idea is that Commanding allows us to have thin UI layers and then testable ViewModels/Presenters. The View Models and Presenters we do test heavily. It's like in ASP.Net MVC, we do MVC so we don't have to test the views*.

*- To be sure, views can still be tested, but I think most people are moving away from the button pushing/angle bracket testing of MVC apps.

Erik Mork
A: 

There is an open source framework called Silverunit CThru, that sits on top of Typemock, that can help you we when unit testing Silverlight. It's a real unit testing framework (the original is more of an integration test system). Cthru contains components that let you test Silverlight controls like real unit tests.