11

Testing WPF and Silverlight Applications

WHAT'S IN THIS CHAPTER?

  • Why testing WPF and Silverlight applications is hard
  • The basics of the MVVM pattern

Windows Presentation Foundation (WPF) and Silverlight are both powerful frameworks that allow you to create visually stunning applications. Both frameworks use Extensible Application Markup Language (XAML) as their markup language. WPF is used for creating desktop-based applications, and Silverlight is used to develop mostly browser-based applications and Windows Phone 7 applications. Despite the fact that these technologies are extremely powerful, testing applications developed using these frameworks can be difficult. Following in the footsteps of previous technologies such as ASP.NET and WinForms, WPF and Silverlight both default to using code-behind files. Code-behind files are great for getting an application up and running quickly, but they make it extremely difficult, if not impossible, to write automated tests for your applications. Code-behind-based applications can also be difficult to maintain, especially as more and more functionality is added. In the world of ASP.NET, the MVC pattern has become the standard for creating highly testable applications while avoiding the pain points of the code-behind.

By the end of this chapter, you will have an understanding of why testing the user interface is difficult. You will learn about patterns that help alleviate some, if not most, of the difficulty of testing WPF and Silverlight-based ...

Get Professional Test-Driven Development with C#: Developing Real World Applications with TDD now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.