CollectionAssert.AreNotEqual 方法 (ICollection, ICollection, IComparer, 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, _
    comparer As IComparer, _
    message As String, _
    ParamArray parameters As Object() _
)
public static void AreNotEqual(
    ICollection notExpected,
    ICollection actual,
    IComparer comparer,
    string message,
    params Object[] parameters
)
public:
static void AreNotEqual(
    ICollection^ notExpected, 
    ICollection^ actual, 
    IComparer^ comparer, 
    String^ message, 
    ... array<Object^>^ parameters
)
static member AreNotEqual : 
        notExpected:ICollection * 
        actual:ICollection * 
        comparer:IComparer * 
        message:string * 
        parameters:Object[] -> unit 
public static function AreNotEqual(
    notExpected : ICollection, 
    actual : ICollection, 
    comparer : IComparer, 
    message : String, 
    ... parameters : Object[]
)

参数

  • message
    类型:System.String
    断言失败时显示的消息。在单元测试结果中可以看到此消息。
  • parameters
    类型:array<System.Object[]
    设置 message 格式时使用的参数的数组。

异常

异常 条件
AssertFailedException

expected 等于 actual。

备注

如果两个集合中的元素相同,而且这些元素的顺序和数量均相同,则这两个集合相等。 如果元素的值相等(而不是引用同一个对象),则元素相等。

.NET Framework 安全性

请参见

参考

CollectionAssert 类

AreNotEqual 重载

Microsoft.VisualStudio.TestTools.UnitTesting 命名空间

其他资源

使用 Assert 类