1 / 14

Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework

Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework. By, Ben Dewey Senior Software Developer Tallan , Inc. ben@bendewey.com http ://bendewey.com/blog http://twitter.com/bendewey. Assumptions. Basic knowledge of Silverlight Unit Testing

herbst
Download Presentation

Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unit Testing your Silverlight Applications Using the Silverlight Unit Testing Framework By, Ben Dewey Senior Software Developer Tallan, Inc. ben@bendewey.com http://bendewey.com/blog http://twitter.com/bendewey

  2. Assumptions • Basic knowledge of • Silverlight • Unit Testing • Nice to have knowledge of • MSTest

  3. Overview • What is Testing/TDD • Setting up the Silverlight Unit Testing Test Harness • Basic Unit Test • Asynchronous Unit Tests • Questions

  4. Preface • Unit Testing (MSTest) [TestMethod] publicvoidCan_AddNumbers() { // Arrange var calculator = newCalculator(); // 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

  5. Original Unit Testing Framework

  6. April 2010 Silverlight Toolkit • http://silverlight.codeplex.com

  7. Setting up the Test Harness • Add Project • Silverlight Unit Testing Applications

  8. Setting up the Test Harness • Add References • Microsoft.Silverlight.Testing • Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight • Modify App.xaml.cs private voidApplication_Startup(object sender, StartupEventArgs e){RootVisual = UnitTestSystem.CreateTestPage();}

  9. Context

  10. Demo

  11. Asynchronous Unit Tests [TestClass]    public classMainPageTests : SilverlightTest    {         [TestMethod, Asynchronous]        public voidCan_ShowHide_Windows()        {            // Arrangevar controller = new GameController();varmainPage = new MainPage(controller);this.TestPanel.Children.Add(mainPage);varstartWindow = mainPage.FindName("StartWindow") asUIElement;varendWindow = mainPage.FindName("EndWindow") asUIElement;EnqueueDelay(500);EnqueueCallback(() =>            { // Actcontroller.ShowStartScreen  = false;             // AssertAssert.AreEqual(Visibility.Collapsed, startWindow.Visibility);Assert.AreEqual(Visibility.Collapsed, endWindow.Visibility); });EnqueueDelay(500);EnqueueTestComplete();        }     }

  12. Links • http://silverlight.codeplex.com • http://www.jeff.wilcox.name/ • Jeff Wilcox – Creator of SUT

  13. Microsoft Design Toolbox http://microsoft.com/design/toolbox

  14. Thank You By, Ben Dewey ben@bendewey.com http://bendewey.com/blog http://twitter.com/bendewey

More Related