MSDN Library
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

HostTypeAttribute Class

 

Specifies the type of host on which the associated unit test will run. This class cannot be inherited.

Namespace:   Microsoft.VisualStudio.TestTools.UnitTesting
Assembly:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)

System::Object
  System::Attribute
    Microsoft.VisualStudio.TestTools.UnitTesting::HostTypeAttribute

[AttributeUsageAttribute(AttributeTargets::Method, AllowMultiple = false)]
public ref class HostTypeAttribute sealed : Attribute

NameDescription
System_CAPS_pubmethodHostTypeAttribute(String^)

Initializes a new instance of the HostTypeAttribute class. This is instantiated by using an argument that specifies the type of host on which this unit test will run.

System_CAPS_pubmethodHostTypeAttribute(String^, String^)

Initializes a new instance of the HostTypeAttribute class. This is instantiated by using an argument that specifies the type of host on which this unit test will run, and custom data for the host adapter.

NameDescription
System_CAPS_pubpropertyHostData

Gets custom data for the host adapter.

System_CAPS_pubpropertyHostType

Gets a value that represents the type of host.

System_CAPS_pubpropertyTypeId

(Inherited from Attribute.)

NameDescription
System_CAPS_pubmethodEquals(Object^)

(Inherited from Attribute.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Attribute.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodIsDefaultAttribute()

(Inherited from Attribute.)

System_CAPS_pubmethodMatch(Object^)

(Inherited from Attribute.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

The type of host identifies the test run on the host, outside the current environment. When a test is run in a different environment, it might also run in a different process. The following example shows that the test is being run in the ASP.NET Development Server address space. This is designated by the AspNetDevelopmentServerHostAttribute. Visual Studio 2005 includes one host adapter called ASP.NET. This is used for ASP.NET unit tests. Customers can create their own host adapters through Visual Studio Industry Partner (VSIP) program.

System_CAPS_noteNote

The Visual Studio software development kit (SDK) contains a sample application named "VSIdeHostAdapter." As an example host adapter, it demonstrates how to create a host adapter that runs tests inside a Visual Studio process.

The HostTypeAttribute can be specified on a test method. Only a single instance of this attribute can occur on a method.

For more information about how to use attributes, see Extending Metadata Using Attributes.

Legacy Code Example

[TestMethod()]
[HostType("ASP.NET")]
[UrlToTest("http://localhost:1371/webSite12")]
[AspNetDevelopmentServerHost("d:\\MyWebSite", "/MyWebSiteRoot")]
public void ConstructorTest()
{
   object target = TestProject1.Class1Accessor.CreatePrivate();
   Assert.Inconclusive("TODO: Implement code to verify target");
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft