CollectionAssert.AllItemsAreInstancesOfType 方法 (ICollection, Type)
验证指定集合中的所有元素是否为指定类型的实例。 如果在任何元素的继承层次结构中都找不到该类型,则断言失败。
命名空间: Microsoft.VisualStudio.TestTools.UnitTesting
程序集: Microsoft.VisualStudio.QualityTools.UnitTestFramework(在 Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 中)
语法
声明
Public Shared Sub AllItemsAreInstancesOfType ( _
collection As ICollection, _
expectedType As Type _
)
public static void AllItemsAreInstancesOfType(
ICollection collection,
Type expectedType
)
public:
static void AllItemsAreInstancesOfType(
ICollection^ collection,
Type^ expectedType
)
static member AllItemsAreInstancesOfType :
collection:ICollection *
expectedType:Type -> unit
public static function AllItemsAreInstancesOfType(
collection : ICollection,
expectedType : Type
)
参数
- collection
类型:System.Collections.ICollection
要验证的集合。
- expectedType
类型:System.Type
预计能够在 collection 中各个元素的继承层次结构中找到的类型。
异常
异常 | 条件 |
---|---|
AssertFailedException | collection 中的一个元素为 nullnull 引用(在 Visual Basic 中为 Nothing),或者在 collection 中所有元素的继承层次结构中都找不到 expectedType。 |
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.VisualStudio.TestTools.UnitTesting 命名空间