Assert.AreNotSame Method

Definition

Overloads

AreNotSame(Object, Object, String, Object[])

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

AreNotSame(Object, Object, String)

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

AreNotSame(Object, Object)

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

AreNotSame<T>(T, T)

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

AreNotSame<T>(T, T, Assert.AssertAreNotSameInterpolatedStringHandler<T>)

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

AreNotSame<T>(T, T, String)

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

AreNotSame<T>(T, T, String, Object[])

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

AreNotSame(Object, Object, String, Object[])

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

C#
public static void AreNotSame(object notExpected, object actual, string message, params object[] parameters);

Parameters

notExpected
Object

The first object to compare. This is the value the test expects not to match actual.

actual
Object

The second object to compare. This is the value produced by the code under test.

message
String

The message to include in the exception when actual is the same as notExpected. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if notExpected refers to the same object as actual.

Applies to

MSTest.TestFramework 2.2.10 et autres versions
Produit Versions
MSTest.TestFramework 1.1.18, 1.2.1, 1.3.2, 1.4.0, 2.2.0, 2.1.2, 2.2.10

AreNotSame(Object, Object, String)

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

C#
public static void AreNotSame(object notExpected, object actual, string message);

Parameters

notExpected
Object

The first object to compare. This is the value the test expects not to match actual.

actual
Object

The second object to compare. This is the value produced by the code under test.

message
String

The message to include in the exception when actual is the same as notExpected. The message is shown in test results.

Exceptions

Thrown if notExpected refers to the same object as actual.

Applies to

MSTest.TestFramework 2.2.10 et autres versions
Produit Versions
MSTest.TestFramework 1.1.18, 1.2.1, 1.3.2, 1.4.0, 2.2.0, 2.1.2, 2.2.10

AreNotSame(Object, Object)

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

C#
public static void AreNotSame(object notExpected, object actual);

Parameters

notExpected
Object

The first object to compare. This is the value the test expects not to match actual.

actual
Object

The second object to compare. This is the value produced by the code under test.

Exceptions

Thrown if notExpected refers to the same object as actual.

Applies to

MSTest.TestFramework 2.2.10 et autres versions
Produit Versions
MSTest.TestFramework 1.1.18, 1.2.1, 1.3.2, 1.4.0, 2.2.0, 2.1.2, 2.2.10

AreNotSame<T>(T, T)

Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

C#
public static void AreNotSame<T>(T? notExpected, T? actual);

Type Parameters

T

The type of values to compare.

Parameters

notExpected
T

The first object to compare. This is the value the test expects not to match actual.

actual
T

The second object to compare. This is the value produced by the code under test.

Exceptions

Thrown if notExpected refers to the same object as actual.

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

AreNotSame<T>(T, T, Assert.AssertAreNotSameInterpolatedStringHandler<T>)

Source:
Assert.AreSame.cs

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

C#
public static void AreNotSame<T>(T? notExpected, T? actual, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertAreNotSameInterpolatedStringHandler<T> message);

Type Parameters

T

The type of values to compare.

Parameters

notExpected
T

The first object to compare. This is the value the test expects not to match actual.

actual
T

The second object to compare. This is the value produced by the code under test.

message
Assert.AssertAreNotSameInterpolatedStringHandler<T>

The message to include in the exception when actual is the same as notExpected. The message is shown in test results.

Applies to

MSTest.TestFramework 3.8.0
Produit Versions
MSTest.TestFramework 3.8.0

AreNotSame<T>(T, T, String)

Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

C#
public static void AreNotSame<T>(T? notExpected, T? actual, string? message);

Type Parameters

T

The type of values to compare.

Parameters

notExpected
T

The first object to compare. This is the value the test expects not to match actual.

actual
T

The second object to compare. This is the value produced by the code under test.

message
String

The message to include in the exception when actual is the same as notExpected. The message is shown in test results.

Exceptions

Thrown if notExpected refers to the same object as actual.

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0

AreNotSame<T>(T, T, String, Object[])

Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs
Source:
Assert.AreSame.cs

Tests whether the specified objects refer to different objects and throws an exception if the two inputs refer to the same object.

C#
public static void AreNotSame<T>(T? notExpected, T? actual, string? message, params object?[]? parameters);

Type Parameters

T

The type of values to compare.

Parameters

notExpected
T

The first object to compare. This is the value the test expects not to match actual.

actual
T

The second object to compare. This is the value produced by the code under test.

message
String

The message to include in the exception when actual is the same as notExpected. The message is shown in test results.

parameters
Object[]

An array of parameters to use when formatting message.

Exceptions

Thrown if notExpected refers to the same object as actual.

Applies to

MSTest.TestFramework 3.8.0 et autres versions
Produit Versions
MSTest.TestFramework 3.0.4, 3.1.1, 3.2.2, 3.3.1, 3.4.3, 3.5.1, 3.6.4, 3.7.3, 3.8.0