forked from xunit/assert.xunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEquivalenceAsserts.cs
44 lines (42 loc) · 1.38 KB
/
EquivalenceAsserts.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
#if XUNIT_NULLABLE
#nullable enable
#endif
using Xunit.Internal;
namespace Xunit
{
#if XUNIT_VISIBILITY_INTERNAL
internal
#else
public
#endif
partial class Assert
{
/// <summary>
/// Verifies that two objects are equivalent, using a default comparer. This comparison is done
/// without regard to type, and only inspects public property and field values for individual
/// equality. Deep equivalence tests (meaning, property or fields which are themselves complex
/// types) are supported. With strict mode off, object comparison allows <paramref name="actual"/>
/// to have extra public members that aren't part of <paramref name="expected"/>, and collection
/// comparison allows <paramref name="actual"/> to have more data in it than is present in
/// <paramref name="expected"/>; with strict mode on, those rules are tightened to require exact
/// member list (for objects) or data (for collections).
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="strict">A flag which enables strict comparison mode</param>
public static void Equivalent(
#if XUNIT_NULLABLE
object? expected,
object? actual,
#else
object expected,
object actual,
#endif
bool strict = false)
{
var ex = AssertHelper.VerifyEquivalence(expected, actual, strict);
if (ex != null)
throw ex;
}
}
}