共用方式為


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

確認兩個指定的集合不相等。 如果這些集合都相等,判斷提示就會失敗。 如果判斷提示失敗,便顯示一則訊息,並套用指定的格式。

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

語法

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

參數

  • notExpected
    類型:ICollection

    要比較的第一個集合。 這是單元測試預期不會符合 actual 的集合。

  • actual
    類型:ICollection

    要比較的第二個集合。 這是單元測試所產生的集合。

  • message
    類型:String

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

  • parameters
    類型:array<Object[]

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

例外狀況

例外狀況 條件
AssertFailedException

expected 等於 actual。

備註

如果兩個集合具有相同的項目且順序和數量也相同,它們就是相等。 如果項目的值相等,它們就相等,但是如果它們參考相同的物件,則不相等。 項目的值預設會使用 Equals 進行比較。

.NET Framework 安全性

請參閱

參考

CollectionAssert 類別

AreNotEqual 多載

Microsoft.VisualStudio.TestTools.UnitTesting 命名空間

其他資源

使用 Assert 類別