forked from xunit/assert.xunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetAsserts.cs
73 lines (65 loc) · 3.28 KB
/
SetAsserts.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
61
62
63
64
65
66
67
68
69
70
71
72
73
using System.Collections.Generic;
using Xunit.Sdk;
namespace Xunit
{
#if XUNIT_VISIBILITY_INTERNAL
internal
#else
public
#endif
partial class Assert
{
/// <summary>
/// Verifies that a set is a proper subset of another set.
/// </summary>
/// <typeparam name="T">The type of the object to be verified</typeparam>
/// <param name="expectedSuperset">The expected superset</param>
/// <param name="actual">The set expected to be a proper subset</param>
/// <exception cref="ContainsException">Thrown when the actual set is not a proper subset of the expected set</exception>
public static void ProperSubset<T>(ISet<T> expectedSuperset, ISet<T> actual)
{
Assert.GuardArgumentNotNull("expectedSuperset", expectedSuperset);
if (actual == null || !actual.IsProperSubsetOf(expectedSuperset))
throw new ProperSubsetException(expectedSuperset, actual);
}
/// <summary>
/// Verifies that a set is a proper superset of another set.
/// </summary>
/// <typeparam name="T">The type of the object to be verified</typeparam>
/// <param name="expectedSubset">The expected subset</param>
/// <param name="actual">The set expected to be a proper superset</param>
/// <exception cref="ContainsException">Thrown when the actual set is not a proper superset of the expected set</exception>
public static void ProperSuperset<T>(ISet<T> expectedSubset, ISet<T> actual)
{
Assert.GuardArgumentNotNull("expectedSubset", expectedSubset);
if (actual == null || !actual.IsProperSupersetOf(expectedSubset))
throw new ProperSupersetException(expectedSubset, actual);
}
/// <summary>
/// Verifies that a set is a subset of another set.
/// </summary>
/// <typeparam name="T">The type of the object to be verified</typeparam>
/// <param name="expectedSuperset">The expected superset</param>
/// <param name="actual">The set expected to be a subset</param>
/// <exception cref="ContainsException">Thrown when the actual set is not a subset of the expected set</exception>
public static void Subset<T>(ISet<T> expectedSuperset, ISet<T> actual)
{
Assert.GuardArgumentNotNull("expectedSuperset", expectedSuperset);
if (actual == null || !actual.IsSubsetOf(expectedSuperset))
throw new SubsetException(expectedSuperset, actual);
}
/// <summary>
/// Verifies that a set is a superset of another set.
/// </summary>
/// <typeparam name="T">The type of the object to be verified</typeparam>
/// <param name="expectedSubset">The expected subset</param>
/// <param name="actual">The set expected to be a superset</param>
/// <exception cref="ContainsException">Thrown when the actual set is not a superset of the expected set</exception>
public static void Superset<T>(ISet<T> expectedSubset, ISet<T> actual)
{
Assert.GuardArgumentNotNull("expectedSubset", expectedSubset);
if (actual == null || !actual.IsSupersetOf(expectedSubset))
throw new SupersetException(expectedSubset, actual);
}
}
}