Automated Unit Testing in Silverlight for Windows Phone 7

4,390 views

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
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
4,390
On SlideShare
0
From Embeds
0
Number of Embeds
125
Actions
Shares
0
Downloads
42
Comments
0
Likes
0
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>http://dotnet.kapenilattex.com </li></ul><ul><li>http://twitter.com/LaTtEX </li></ul><ul><li>http://facebook.com/LaTtEX </li></ul>
  19. 19. References <ul><li>Introduction to Model/View/ViewModel pattern for building WPF apps http:// blogs.msdn.com/b/johngossman/archive/2005/10/08/478683.aspx </li></ul><ul><li>Silverlight Patterns: Model-View-ViewModel in Silverlight 2 apps http:// msdn.microsoft.com/en-us/magazine/dd458800.aspx </li></ul><ul><li>Model-View-ViewModel (MVVM) Explained http:// csharperimage.jeremylikness.com/2010/04/model-view-viewmodel-mvvm-explained.html </li></ul><ul><li>Introduction to Test Driven Development http://dotnet.kapenilattex.com/? p=201 </li></ul><ul><li>Windows Phone 7 Tutorials http:// compiledexperience.com/windows-phone-7 </li></ul><ul><li>Updated Silverlight Unit Testing Framework bits for Windows Phone and Silverlight 3 http://www.jeff.wilcox.name/2010/05/sl3-utf-bits / </li></ul><ul><li>Steps to run the Windows Phone 7 Unit Test Framework successfully http:// codingsolutions.blogspot.com/2010/03/steps-to-run-windows-phone-7-unit-test.html </li></ul><ul><li>TDD Kata for Windows Phone 7 http:// github.com/dgadd/TDD_Kata_For_MVVM_on_Win_Phone_7 </li></ul><ul><li>Migrating Apps from Windows Phone April CTP Refresh to Beta Build http ://blogs.msdn.com/b/jaimer/archive/2010/06/28/migrating-apps-from-windows-phone-ctps-to-the-beta-build.aspx?wa=wsignin1.0 </li></ul>

×