Automated Unit Testing in Silverlight for Windows Phone 7


Published on

A short overview on Test Driven Development and the MVVM Pattern, in the context of applying it in Windows Phone 7

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Automated Unit Testing in Silverlight for Windows Phone 7

  1. 1. Automated Unit Testing with Silverlight for Windows Phone 7 Jacinto Limjap, Jr. Microsoft MVP for C# Senior Applications Developer, FBM e-Services
  2. 2. Agenda <ul><li>Automated unit testing and Test Driven Development </li></ul><ul><li>MVVM – an overview </li></ul><ul><li>Putting it all together using Silverlight for Windows Phone 7 </li></ul>
  3. 3. Any mobile developers in the house?  What do you use in terms of frameworks/patterns/unit testing?
  4. 4. AUTOMATED UNIT TESTING & TDD <ul><li>An introduction </li></ul>
  5. 5. What is Test Driven Development? <ul><li>Using unit tests to design software </li></ul><ul><li>Allows change in code without fear of (inadvertently ) changing functionality </li></ul><ul><li>Produces loosely coupled objects and methods with single responsibilities </li></ul>
  6. 6. What is Test Driven Development? <ul><li>Unit tests are just side effects: main point is DESIGN </li></ul><ul><li>Write tests first, code later (?!) </li></ul>
  7. 7. What is Test Driven Development NOT? <ul><li>Substitute for QA testing </li></ul><ul><li>Necessarily means successful project </li></ul><ul><li>Silver bullet </li></ul>
  8. 8. TDD Mindset
  9. 9. Writing Tests <ul><li>Think about how you want to express your code and intentions </li></ul><ul><li>Think about inputs, and intended output </li></ul><ul><li>Separate small, isolated areas of functionality </li></ul>
  10. 10. Issues <ul><li>Unit tests should come BEFORE code </li></ul><ul><li>Unit tests should NOT depend on presence or absence or external dependencies (e.g., storage, database, internet connection) </li></ul><ul><li>How to solve this: Mocks, stubs and fakes </li></ul>
  11. 11. Do we really have to do test first? 
  12. 12. MVVM <ul><li>The Model View ViewModel Pattern </li></ul>
  13. 13. Model-View-ViewModel <ul><li>Introduced in 2005 by John Gossman </li></ul><ul><li>Originally designed for Windows Presentation Foundation (WPF) applications </li></ul><ul><li>Designed in response to attempts to use Model-View-Controller (MVC) in WPF </li></ul>
  14. 14. Model-View-ViewModel <ul><li>Model – class or data representation of object you are using within your application </li></ul><ul><li>View – the part of your application representing the user interface </li></ul><ul><li>ViewModel – class or data representation of an object or combination of objects, as seen in the View </li></ul>
  15. 15. Model-View-ViewModel View (XAML) View Model Model Data Binding
  16. 16. So why is MVVM important?
  17. 17. DEMO <ul><li>Unit testing on Silverlight for Windows Phone 7 </li></ul>
  18. 18. Discussion <ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul>
  19. 19. References <ul><li>Introduction to Model/View/ViewModel pattern for building WPF apps http:// </li></ul><ul><li>Silverlight Patterns: Model-View-ViewModel in Silverlight 2 apps http:// </li></ul><ul><li>Model-View-ViewModel (MVVM) Explained http:// </li></ul><ul><li>Introduction to Test Driven Development p=201 </li></ul><ul><li>Windows Phone 7 Tutorials http:// </li></ul><ul><li>Updated Silverlight Unit Testing Framework bits for Windows Phone and Silverlight 3 / </li></ul><ul><li>Steps to run the Windows Phone 7 Unit Test Framework successfully http:// </li></ul><ul><li>TDD Kata for Windows Phone 7 http:// </li></ul><ul><li>Migrating Apps from Windows Phone April CTP Refresh to Beta Build http :// </li></ul>