共用方式為


CollectionAssert.DoesNotContain 方法 (ICollection, Object, String, array<Object[])

確認指定的集合不包含指定的項目。 如果此項目位於集合中,判斷提示就會失敗。 如果判斷提示失敗,便顯示一則訊息,並套用指定的格式。

命名空間:  Microsoft.VisualStudio.TestTools.UnitTesting
組件:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (在 Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 中)

語法

'宣告
Public Shared Sub DoesNotContain ( _
    collection As ICollection, _
    element As Object, _
    message As String, _
    ParamArray parameters As Object() _
)
public static void DoesNotContain(
    ICollection collection,
    Object element,
    string message,
    params Object[] parameters
)
public:
static void DoesNotContain(
    ICollection^ collection, 
    Object^ element, 
    String^ message, 
    ... array<Object^>^ parameters
)
static member DoesNotContain : 
        collection:ICollection * 
        element:Object * 
        message:string * 
        parameters:Object[] -> unit
public static function DoesNotContain(
    collection : ICollection, 
    element : Object, 
    message : String, 
    ... parameters : Object[]
)

參數

  • collection
    類型:ICollection

    用來搜尋項目的集合。

  • element
    類型:Object

    不預期會在集合中的項目。

  • message
    類型:String

    要在判斷提示失敗時顯示的訊息。 這項訊息會在單元測試結果中出現。

  • parameters
    類型:array<Object[]

    在格式化 message 時所要使用的參數陣列。

例外狀況

例外狀況 條件
AssertFailedException

collection 是在 element 中。

.NET Framework 安全性

請參閱

參考

CollectionAssert 類別

DoesNotContain 多載

Microsoft.VisualStudio.TestTools.UnitTesting 命名空間

其他資源

使用 Assert 類別