CollectionAssert.AllItemsAreNotNull 方法 (ICollection, String)
验证指定集合中的所有项是否都不为 nullnull 引用(在 Visual Basic 中为 Nothing)。 如果有任何元素为 nullnull 引用(在 Visual Basic 中为 Nothing),则断言失败。 如果断言失败,将显示一则消息。
命名空间: Microsoft.VisualStudio.TestTools.UnitTesting
程序集: Microsoft.VisualStudio.QualityTools.UnitTestFramework(在 Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 中)
语法
声明
Public Shared Sub AllItemsAreNotNull ( _
collection As ICollection, _
message As String _
)
public static void AllItemsAreNotNull(
ICollection collection,
string message
)
public:
static void AllItemsAreNotNull(
ICollection^ collection,
String^ message
)
static member AllItemsAreNotNull :
collection:ICollection *
message:string -> unit
public static function AllItemsAreNotNull(
collection : ICollection,
message : String
)
参数
- collection
类型:System.Collections.ICollection
要在其中搜索 nullnull 引用(在 Visual Basic 中为 Nothing) 元素的集合。
- message
类型:System.String
断言失败时显示的消息。在单元测试结果中可以看到此消息。
异常
异常 | 条件 |
---|---|
AssertFailedException | 在 collection 中找到了一个 nullnull 引用(在 Visual Basic 中为 Nothing) 元素。 |
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.VisualStudio.TestTools.UnitTesting 命名空间