100 likes | 241 Views
Silverlight Unit Testing. About Me: Eric Hexter Director of Austin .Net User Group AspInsiders Organized the 2007 Austin Code Camp Build websites and web applications since 1996 Unit Testing since 2004 Test Infected since 2006. Agenda. What is Silverlight
E N D
Silverlight Unit Testing • About Me: Eric Hexter • Director of Austin .Net User Group • AspInsiders • Organized the 2007 Austin Code Camp • Build websites and web applications since 1996 • Unit Testing since 2004 • Test Infected since 2006
Agenda • What is Silverlight • Why do you need a whole session on unit testing? • SilverlightRuntime • Types of Tests • Unit Test Pattern • Testing Framework Choices • Code • Async • Tips & Tricks • Resources
What is Silverlight • Silverlight 2.0 • Rich Internet Application platform • It is a Web technology • Subset of the .Net Runtime • Runs cross platform – Windows/Linux/Mac • Runs cross browser – IE/Firefox/Safari • Silverlight 1.0 = Javascript • Silverlight 2.0 = .Net – C#,Vb.Net,dynamic languages….
Why a session on unit testing? • The standard solutions for unit testing do not apply. • The CLR is a subset of .Net • Currently no Mocking support • All networking is Async • The Test Framework can solve solutions which were previously solved by multiple solutions.. ienUnit + Watir/ Selenium
Types of Tests • Unit Test • Tests a single method for a single assertion • Integration Test • Test the interaction of multiple classes . • Can leave the process boundry. Make calls to webservices…ect. • Smoke Tests • Tests the happy path by pushing the UI to perform user based test cases.
Unit Test Pattern – The 3-As • Arrange • Act • Assert • See Code Sample - UnitTestSample
Testing Framework Choices • Silverlight Test Framework • Unit Tests – run all tests • Integration Tests • Smoke Tests • TestDriven.Net • Unit Tests – single test execution • nUnit(Silverlight Project Template) • Unit Tests • Some Integration Tests
Using Test Framework • Show Project References • Special Project Templates • Test Framework Runner • Why Asynchronous Tests • Silverlight User Interfaces can be async. • Out of process calls are async. • Sample….
Tips and Tricks • Making the Asynchronous tests palatable • Easier to read… Easier to remember months later • Less clutter / easier to meet the 3As • A fluent interface wrapper.. • Sample
Resources • Eric Hexter’s Blog • http://hex.LosTechies.com • Jeff Wilcox • Jaime C