Share via


Assert.IsInstanceOfType 方法 (Object, Type)

验证指定的对象是否为指定类型的实例。 如果在该对象的继承层次结构中找不到该类型,则断言失败。

命名空间:  Microsoft.VisualStudio.TestTools.UnitTesting
程序集:  Microsoft.VisualStudio.QualityTools.UnitTestFramework(在 Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 中)

语法

声明
Public Shared Sub IsInstanceOfType ( _
    value As Object, _
    expectedType As Type _
)
public static void IsInstanceOfType(
    Object value,
    Type expectedType
)
public:
static void IsInstanceOfType(
    Object^ value, 
    Type^ expectedType
)
static member IsInstanceOfType : 
        value:Object * 
        expectedType:Type -> unit 
public static function IsInstanceOfType(
    value : Object, 
    expectedType : Type
)

参数

  • value
    类型:System.Object
    要验证的对象属于 expectedType。
  • expectedType
    类型:System.Type
    预计能够在 value 的继承层次结构中找到的类型。

异常

异常 条件
AssertFailedException

value 为 nullnull 引用(在 Visual Basic 中为 Nothing),或者在 value 的继承层次结构中找不到 expectedType。

.NET Framework 安全性

请参见

参考

Assert 类

IsInstanceOfType 重载

Microsoft.VisualStudio.TestTools.UnitTesting 命名空间

其他资源

使用 Assert 类