Share via


Assert.AreNotSame 方法 (Object, Object, String)

验证指定的两个对象变量是否引用不同的对象。 如果它们引用同一个对象,则断言失败。 如果断言失败,将显示一则消息。

命名空间:  Microsoft.VisualStudio.TestTools.UnitTesting
程序集:  Microsoft.VisualStudio.QualityTools.UnitTestFramework(在 Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 中)

语法

声明
Public Shared Sub AreNotSame ( _
    notExpected As Object, _
    actual As Object, _
    message As String _
)
public static void AreNotSame(
    Object notExpected,
    Object actual,
    string message
)
public:
static void AreNotSame(
    Object^ notExpected, 
    Object^ actual, 
    String^ message
)
static member AreNotSame : 
        notExpected:Object * 
        actual:Object * 
        message:string -> unit 
public static function AreNotSame(
    notExpected : Object, 
    actual : Object, 
    message : String
)

参数

  • notExpected
    类型:System.Object
    要比较的第一个对象。单元测试要求该对象与 actual 不匹配。
  • actual
    类型:System.Object
    要比较的第二个对象。这是单元测试生成的对象。
  • message
    类型:System.String
    断言失败时显示的消息。在单元测试结果中可以看到此消息。

异常

异常 条件
AssertFailedException

notExpected 与 actual 引用相同的对象。

.NET Framework 安全性

请参见

参考

Assert 类

AreNotSame 重载

Microsoft.VisualStudio.TestTools.UnitTesting 命名空间

其他资源

使用 Assert 类