-
Notifications
You must be signed in to change notification settings - Fork 83
/
IdentityAsserts.cs
60 lines (56 loc) · 1.47 KB
/
IdentityAsserts.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma warning disable CA1052 // Static holder types should be static
#pragma warning disable IDE0161 // Convert to file-scoped namespace
#if XUNIT_NULLABLE
#nullable enable
#endif
using Xunit.Sdk;
namespace Xunit
{
#if XUNIT_VISIBILITY_INTERNAL
internal
#else
public
#endif
partial class Assert
{
/// <summary>
/// Verifies that two objects are not the same instance.
/// </summary>
/// <param name="expected">The expected object instance</param>
/// <param name="actual">The actual object instance</param>
/// <exception cref="NotSameException">Thrown when the objects are the same instance</exception>
public static void NotSame(
#if XUNIT_NULLABLE
object? expected,
object? actual)
#else
object expected,
object actual)
#endif
{
if (object.ReferenceEquals(expected, actual))
throw NotSameException.ForSameValues();
}
/// <summary>
/// Verifies that two objects are the same instance.
/// </summary>
/// <param name="expected">The expected object instance</param>
/// <param name="actual">The actual object instance</param>
/// <exception cref="SameException">Thrown when the objects are not the same instance</exception>
public static void Same(
#if XUNIT_NULLABLE
object? expected,
object? actual)
#else
object expected,
object actual)
#endif
{
if (!object.ReferenceEquals(expected, actual))
throw SameException.ForFailure(
ArgumentFormatter.Format(expected),
ArgumentFormatter.Format(actual)
);
}
}
}