Presentation is loading. Please wait.

Presentation is loading. Please wait.

By, Ben Dewey Senior Software Developer Tallan, Inc.

Similar presentations


Presentation on theme: "By, Ben Dewey Senior Software Developer Tallan, Inc."— Presentation transcript:

1 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] 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

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 void Application_Startup(object sender, StartupEventArgs e) { RootVisual = UnitTestSystem.CreateTestPage(); }

9 Context

10

11 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(); } }

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 By, Ben Dewey ben@bendewey.com http://bendewey.com/blog http://twitter.com/bendewey


Download ppt "By, Ben Dewey Senior Software Developer Tallan, Inc."

Similar presentations


Ads by Google