How to: Upgrade Database Unit Tests from Previous Releases of Visual Studio

This topic applies to:

Visual Studio Ultimate

Visual Studio Premium

Visual Studio Professional 

Visual Studio Express

Topic applies Topic applies Topic applies Topic does not apply

If you open a solution that contains a database project and a database unit test project, you are presented with the option to upgrade both projects to work with Visual Studio 2010. However, if you open a solution that only contains a database unit test project or if you open the project outside a solution, then you must manually upgrade the database unit test project as described in this topic. Otherwise, if you try to rebuild unit tests that you created in a previous release of Visual Studio, build errors will appear. You must update your project to use updated assembly names and namespaces. After you have made several simple changes, you can rebuild and run your unit tests.

You must make three sets of changes:

  • Change the assembly references to reference a new assembly.

  • Change your code so that the Imports or using statements reflect the updated namespaces.

  • Change your code so that any references to types that are defined in the referenced namespaces reflect the updated namespaces.

To update assembly references for your unit test project

  1. In Solution Explorer, expand the References folder in the unit test project that you want to update.

  2. Right-click the Microsoft.VisualStudio.TeamSystem.Data.UnitTesting reference, and then click Remove.

  3. Right-click the References folder, and then click Add Reference.

  4. On the list on the .NET tab, click Microsoft.Data.Schema.UnitTesting. and Microsoft.Data.Schema.

    Note

    You must reference the 10.0.0.0 versions of these assemblies, instead of the 9.1.0.0 version that was used the previous release.

  5. Click OK.

    Next, you will update the code to update all references to the updated namespaces.

To update the code in your unit test project

  1. In Solution Explorer, right-click DatabaseSetup.vb (if your project was created by using Visual Basic) or right-click DatabaseSetup.cs (if your project was created by using Visual C#), and then click View Code.

  2. In the code editor, replace all references to Microsoft.VisualStudio.TeamSystem.Data.UnitTesting with Microsoft.Data.Schema.UnitTesting.

    Note

    This includes updating Microsoft.VisualStudio.TeamSystem.Data.UnitTesting.Conditions to be Microsoft.Data.Schema.UnitTesting.Conditions.

  3. For each class in your database unit test project, view the code in the code editor, and replace all references to Microsoft.VisualStudio.TeamSystem.Data.UnitTesting with Microsoft.Data.Schema.UnitTesting.

    Note

    This includes updating Microsoft.VisualStudio.TeamSystem.Data.UnitTesting.Conditions to be Microsoft.Data.Schema.UnitTesting.Conditions.

  4. On the File menu, click Save All.

    You can now rebuild your database unit test projects, and any errors related to the upgrade should be resolved. If your unit tests use custom unit test conditions, you will also have to upgrade those before your tests will run successfully.

See Also

Tasks

How to: Upgrade a Custom Test Condition from a Previous Release

Concepts

Upgrading Database Projects from Previous Releases of Visual Studio