unit testing your silverlight applications using the silverlight unit testing framework
DESCRIPTION
Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework. By, Ben Dewey Senior Software Developer Tallan , Inc. [email protected] http ://bendewey.com/blog http://twitter.com/bendewey. Assumptions. Basic knowledge of Silverlight Unit Testing - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/1.jpg)
Unit Testing your Silverlight Applications Using the Silverlight
Unit Testing FrameworkBy, Ben Dewey
Senior Software DeveloperTallan, Inc.
[email protected]://bendewey.com/blog
http://twitter.com/bendewey
![Page 2: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/2.jpg)
AssumptionsBasic knowledge of
SilverlightUnit Testing
Nice to have knowledge ofMSTest
![Page 3: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/3.jpg)
OverviewWhat is Testing/TDDSetting up the Silverlight Unit Testing Test HarnessBasic Unit TestAsynchronous Unit TestsQuestions
![Page 4: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/4.jpg)
PrefaceUnit Testing (MSTest)
[TestMethod]public void Can_AddNumbers(){ // Arrange var calculator = new Calculator();
// Act var result = calculator.Add(1, 2);
// Assert Assert.AreEqual(3, result);}
Test Driven Design (TDD)Testing first and allowing your tests/requirements to drive
your design
![Page 5: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/5.jpg)
Original Unit Testing Framework
![Page 7: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/7.jpg)
Setting up the Test HarnessAdd Project
Silverlight Unit Testing Applications
![Page 8: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/8.jpg)
Setting up the Test HarnessAdd References
Microsoft.Silverlight.TestingMicrosoft.VisualStudio.QualityTools.UnitTesting.Silverlight
Modify App.xaml.cs
private void Application_Startup(object sender, StartupEventArgs e){ RootVisual = UnitTestSystem.CreateTestPage();}
![Page 9: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/9.jpg)
Context
![Page 10: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/10.jpg)
Demo
![Page 11: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/11.jpg)
Asynchronous Unit Tests [TestClass] public class MainPageTests : SilverlightTest { [TestMethod, Asynchronous] public void Can_ShowHide_Windows() { // Arrange var controller = new GameController(); var mainPage = new MainPage(controller); this.TestPanel.Children.Add(mainPage); var startWindow = mainPage.FindName("StartWindow") as UIElement; var endWindow = mainPage.FindName("EndWindow") as UIElement;
EnqueueDelay(500); EnqueueCallback(() => { // Act controller.ShowStartScreen = false; // Assert Assert.AreEqual(Visibility.Collapsed, startWindow.Visibility); Assert.AreEqual(Visibility.Collapsed, endWindow.Visibility); }); EnqueueDelay(500);
EnqueueTestComplete(); } }
![Page 12: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/12.jpg)
Links
http://silverlight.codeplex.com
http://www.jeff.wilcox.name/Jeff Wilcox – Creator of SUT
![Page 13: Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework](https://reader035.vdocuments.us/reader035/viewer/2022081603/56813e10550346895da7efbb/html5/thumbnails/13.jpg)
Microsoft Design Toolbox
http://microsoft.com/design/toolbox