Assert.IsInstanceOfType Method

Definition

Overloads

IsInstanceOfType(Object, Type, String, Object[])

Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in the inheritance hierarchy of the object.

IsInstanceOfType(Object, Type)

Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in the inheritance hierarchy of the object.

IsInstanceOfType(Object, Type, Assert+AssertIsInstanceOfTypeInterpolatedStringHandler)

Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in the inheritance hierarchy of the object.

IsInstanceOfType(Object, Type, String)

Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in the inheritance hierarchy of the object.

IsInstanceOfType<T>(Object, T, Assert.AssertGenericIsInstanceOfTypeInterpolatedStringHandler<T>)

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

IsInstanceOfType<T>(Object, String, Object[])

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

IsInstanceOfType<T>(Object, T, String)

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

IsInstanceOfType<T>(Object, T, String, Object[])

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

IsInstanceOfType<T>(Object, T)

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

IsInstanceOfType<T>(Object, Assert.AssertGenericIsInstanceOfTypeInterpolatedStringHandler<T>)

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

IsInstanceOfType<T>(Object)

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

IsInstanceOfType<T>(Object, String)

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

IsInstanceOfType(Object, Type, String, Object[])

Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType(object value, Type expectedType, string message, params object[] parameters);
C#
public static void IsInstanceOfType(object? value, Type? expectedType, string? message, params object?[]? parameters);

Parameters

value
Object

The object the test expects to be of the specified type.

expectedType
Type

The expected type of value.

message
String

The message to include in the exception when value is not an instance of expectedType. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if value is null or expectedType is not in the inheritance hierarchy of value.

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 1.1.18, 1.2.1, 1.3.2, 1.4.0, 2.2.0, 2.1.2, 2.2.10, 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

IsInstanceOfType(Object, Type)

Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType(object value, Type expectedType);
C#
public static void IsInstanceOfType(object? value, Type? expectedType);

Parameters

value
Object

The object the test expects to be of the specified type.

expectedType
Type

The expected type of value.

Exceptions

Thrown if value is null or expectedType is not in the inheritance hierarchy of value.

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 1.1.18, 1.2.1, 1.3.2, 1.4.0, 2.2.0, 2.1.2, 2.2.10, 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

IsInstanceOfType(Object, Type, Assert+AssertIsInstanceOfTypeInterpolatedStringHandler)

Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType(object? value, Type? expectedType, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertIsInstanceOfTypeInterpolatedStringHandler message);

Parameters

value
Object

The object the test expects to be of the specified type.

expectedType
Type

The expected type of value.

message
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertIsInstanceOfTypeInterpolatedStringHandler

The message to include in the exception when value is not an instance of expectedType. The message is shown in test results.

Applies to

MSTest.TestFramework 3.8.0
Produit Versions
MSTest.TestFramework 3.8.0

IsInstanceOfType(Object, Type, String)

Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType(object value, Type expectedType, string message);
C#
public static void IsInstanceOfType(object? value, Type? expectedType, string? message);

Parameters

value
Object

The object the test expects to be of the specified type.

expectedType
Type

The expected type of value.

message
String

The message to include in the exception when value is not an instance of expectedType. The message is shown in test results.

Exceptions

Thrown if value is null or expectedType is not in the inheritance hierarchy of value.

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 1.1.18, 1.2.1, 1.3.2, 1.4.0, 2.2.0, 2.1.2, 2.2.10, 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

IsInstanceOfType<T>(Object, T, Assert.AssertGenericIsInstanceOfTypeInterpolatedStringHandler<T>)

Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType<T>(object? value, out T instance, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertGenericIsInstanceOfTypeInterpolatedStringHandler<T> message);

Type Parameters

T

The expected type of value.

Parameters

value
Object
instance
T
message
Assert.AssertGenericIsInstanceOfTypeInterpolatedStringHandler<T>

Applies to

MSTest.TestFramework 3.8.0
Produit Versions
MSTest.TestFramework 3.8.0

IsInstanceOfType<T>(Object, String, Object[])

Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType<T>(object? value, string? message, params object?[]? parameters);

Type Parameters

T

The expected type of value.

Parameters

value
Object
message
String
parameters
Object[]

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

IsInstanceOfType<T>(Object, T, String)

Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType<T>(object? value, out T instance, string? message);

Type Parameters

T

The expected type of value.

Parameters

value
Object
instance
T
message
String

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

IsInstanceOfType<T>(Object, T, String, Object[])

Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType<T>(object? value, out T instance, string? message, params object?[]? parameters);

Type Parameters

T

The expected type of value.

Parameters

value
Object
instance
T
message
String
parameters
Object[]

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

IsInstanceOfType<T>(Object, T)

Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType<T>(object? value, out T instance);

Type Parameters

T

The expected type of value.

Parameters

value
Object
instance
T

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

IsInstanceOfType<T>(Object, Assert.AssertGenericIsInstanceOfTypeInterpolatedStringHandler<T>)

Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType<T>(object? value, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertGenericIsInstanceOfTypeInterpolatedStringHandler<T> message);

Type Parameters

T

The expected type of value.

Parameters

value
Object
message
Assert.AssertGenericIsInstanceOfTypeInterpolatedStringHandler<T>

Applies to

MSTest.TestFramework 3.8.0
Produit Versions
MSTest.TestFramework 3.8.0

IsInstanceOfType<T>(Object)

Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType<T>(object? value);

Type Parameters

T

The expected type of value.

Parameters

value
Object

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

IsInstanceOfType<T>(Object, String)

Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs
Source:
Assert.IsInstanceOfType.cs

Tests whether the specified object is an instance of the generic type and throws an exception if the generic type is not in the inheritance hierarchy of the object.

C#
public static void IsInstanceOfType<T>(object? value, string? message);

Type Parameters

T

The expected type of value.

Parameters

value
Object
message
String

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0