Unit Testing in Silverlight
So i found a good tutorial on silverlight unit testing however it doesn't address issues like styles not being present when you instantiate a page, which throws an error and crashes the test am i supposed 开发者_如何学运维to setup a complete cloned environment like adding in the styles, service references, images, etc into the unit test project?
You've ran into an issue that has plagued software developers for many decades now - how do I test UI? The simplest answer is - don't. This is a generally accepted practice. Instead, design your application such that most of the logic is outside of the UI and built into components. You can then also design your UI logic of the application using patterns such as Model View Controller, Model View Presenter, and Model View View-Model which allow that logic to be tested. XAML based technologies typically lean towards the MVVM pattern.
Here is an intro to MVVM by Jeremy Likness:
http://csharperimage.jeremylikness.com/2010/04/model-view-viewmodel-mvvm-explained.html
精彩评论