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

This topic applies to Visual Studio Premium and Visual Studio Ultimate, but not to Visual Studio 2010 Professional or the Visual Studio Express versions.

In order for an existing test unit condition that you created in an earlier version of Visual Studio to work correctly, you must upgrade it. Doing so requires the following steps:

  • Updating References

  • Adding an Extension Compatibility Attribute

  • Applying the New Registration Process

Updating References

To update the project references

  1. (Visual Basic only) In Solution Explorer, click Show All Files.

  2. In Solution Explorer, expand the References node.

  3. Right-click the previous Microsoft.Data.Schema.UnitTesting reference and click Remove.

  4. In Solution Explorer, right-click the References node and click Add Reference.

    -or-

  5. On the Project menu, click Add Reference.

    The Add Reference dialog box appears.

  6. Click the .NET tab. In the Component Name list, select Microsoft.Data.Schema and Microsoft.Data.Schema.UnitTesting, and then click OK.

    Your test condition is now using the current reference.

Adding an Extension Compatibility Attribute

Next, you must verify that your test condition classes have the extension compatibility attribute, as shown in the following procedure. When you define a feature extension, you declare the compatibility of that extension with either a specific database schema provider (DSP) or a base database schema provider, so that the extension is loaded only for appropriate project types. For more information about the extension compatibility attribute, see Extending the Database Features of Visual Studio.

To add an extension compatibility attribute

  • Add the database service provider extension compatibility attribute, as shown in the following example:

    <DatabaseServicesProviderCompatibility (GetType(DspCompatibilityCategory.None))> _
    <DisplayName("NewTestCondition")> _
    Public Class NewTestCondition
        Inherits TestCondition
    
    End Class
    
    [DatabaseServicesProviderCompatibility(DspCompatibilityCategory.None)]
    [DisplayName("NewTestCondition")]
    public class NewTestCondition:TestCondition
    {
       // Additional implementation to be added here
    }
    

Applying the New Registration Process

In an earlier version of Visual Studio, you were required to install your test condition into the global assembly cache. In this release of Visual Studio Premium or Visual Studio Ultimate, the registration process has changed, as shown in the following procedures. For more information, see How to: Register and Manage Feature Extensions.

Once your updated references are in place, verify that your assembly is signed and compiled.

The next step is to gather the assembly information generated in the project, including the version, the culture, and the PublicKeyToken, to facilitate registering the custom extension assembly.

To gather assembly information

  1. Once your updated references are in place and the extension compatibility attribute has been added, as shown in the previous procedures, verify that your assembly is signed and compiled.

  2. On the View menu, click Other Windows, and then click Command Window to open the Command window.

  3. In the Command window, type the following code. For FilePath, substitute the path and file name of your compiled .dll file. Include the quotation marks around the path and file name.

    Note

    By default, the path of your compiled .dll file is SampleGenerator\bin\Debug.

    ? System.Reflection.Assembly.LoadFrom(@"<FilePath>").FullName
    
  4. Press Enter. The line should resemble the following with your specific PublicKeyToken:

    " GeneratorDateRanges, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nnnnnnnnnnnnnnnn"
    

    Notate or copy this assembly information; it will be used in the next procedure.

Next, you will create an XML file by using the assembly information that you gathered in the previous procedure.

To create the XML file

  1. In Solution Explorer, select the project.

  2. On the Project menu, select Add New Item.

    The Add New Item dialog box appears.

  3. In the Templates pane, locate and select the XML File item.

  4. In the Name text box, enter an applicable name and click the Add button.

    The XML file is added to the project in Solution Explorer.

    Note

    You must use the name of your dll (in this case, "myDllName" followed by ".Extensions.xml") for the assembly to register correctly.

  5. Open the XML file and update it to match the XML code later in this procedure. Replace the assembly's version, culture, and PublicKeyToken that you retrieved in the previous procedure.

    <?xml version="1.0" encoding="utf-8"?>
    <extensions assembly=""
                version="1" xmlns="urn:Microsoft.Data.Schema.Extensions"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="urn:Microsoft.Data.Schema.Extensions 
    
      Microsoft.Data.Schema.Extensions.xsd"> <extension type=" myDllName.myClassName" assembly="myDllName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nnnnnnnnnnnnnnnn" enabled="true"/>
    
    </extensions>
    
  6. On the File menu, click Save All.

Next, you will copy the assembly and XML file to the Extensions directory. When Visual Studio Premium starts, it will identify any extensions in the <Microsoft Visual Studio 10.0>\VSTSDB\Extensions directory and subdirectories and register them for use in the session.

To copy and register the assembly and XML file to the Extensions directory

  1. Create a new folder named CustomGenerators in the <Microsoft Visual Studio 10.0>\VSTSDB\Extensions\ directory.

  2. Copy the assembly file from the My Documents\Visual Studio 2008\Projects\<projectName>\<projectName>\bin\Debug\ directory to the <Microsoft Visual Studio 10.0>\VSTSDB\Extensions\CustomGenerators directory that you created.

  3. Copy the XML file from the My Documents\Visual Studio 2008\Projects\<projectName>\<projectName>\ directory to the <Microsoft Visual Studio 10.0>\VSTSDB\Extensions\CustomGenerators directory that you created.

    Tip

    A best practice is to put your extension assemblies in a folder in the <Microsoft Visual Studio 10.0>\VSTSDB\Extensions directory. This will help you identify which extensions were included with the product, and which ones are your custom creations. Folders are also recommended for organizing your extensions into specific categories.

See Also

Tasks

How to: Create Test Conditions for the Database Unit Test Designer

Walkthrough: Using a Custom Test Condition to Verify the Results of a Stored Procedure