I have several custom controls (some kind of frames for content and layout management, like wrap panel), and would like to write unit tests for them. It's hard to find any good examples except Silverlight control toolkit, which has some helper classes to do unit tests and it's quite complicated. For MVVM classes it's easy to write tests because they don't use SL dependency system and infrastructure.
Questions:
- how to unit test DepedenyProperty, what do I need to test
- how to test attached property
- do I test bindings with theme or UserControl, like simple textblock content binding, or command/event binding in MVVM with UserControl
- what else do I test in my custom controls, beside my business logic
- any good tutorial to achieve tests like those in control toolkit
How do I start? Is SL controls toolkit only option for learning?
For testing framework i'm using one from control toolkit, and for continuus integration on TFS build server I planned to use Statlight (from codeplex). Any advice on that?
Edit:
After some investigation, I was able to write some basic tests for my custom control. I used helper classes from Control Toolkit, which contains lot of predefined tests for specific type of custom control (panels, content controls, ...) and have methods for testing infrastructure functionality like Visual States and Parts. Too bad there's no manual or tutorial because it contains a lot of code there and it takes some time to figure it out, how to use it in your project.
Even my custom control inherits from ContentControl, and there is ContentControlTest i can inherit from to use for my tests, I got too much failed tests. So i used FrameworkElementTest, which contains around 30 tests, plus some of my own, and it's not difficult to pass them all, after figuring out how to prepare the whole thing (initialisation stuff in constructor of test class, and use of DepedenyPropertyTest helper class).
I still don't know what I have to do to pass all tests from ContentControlTest, but i just started and getting into whole testing stuff ;)