,

Creating a Test Project

Test projects are regular Windows Phone App projects with some small modifications. To create a test project, perform the following steps:

1. Add a new Windows Phone App project by selecting File/New/Project in Visual Studio, and select Windows Phone App from the Windows Phone node in the New Project dialog.

2. Click the ellipsis on the Package Manager Console to change the target project to the newly created test project (see Figure 24.1).

Image

FIGURE 24.1 Click the ellipsis to change the target project.

3. From the Visual Studio Tools menu, select Library Package Manager/Package Manager Console.

4. Use NuGet to download the Windows Phone UTF by entering the following command into the Package Manager Console:

Install-Package WPToolkitTestFx

Note that if you receive an error indicating that the package is not compatible with WindowsPhone version 8.0, download the latest version of NuGet from http://www.nuget.org.

5. Modify the test project’s MainPage constructor (in the MainPage.xaml.cs file) to match the following:

public MainPage()
{
    InitializeComponent();
    Content = UnitTestSystem.CreateTestPage();
}

6. Add a reference to the project that you intend to create unit tests for.

A test page instance is assigned to the Content property of the main page. Windows Phone does not allow the assignment of the RootVisual in the App.xaml.cs file. This is why the code to create the test page is placed in the MainPage class and not in the App class.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.47.25