Skip to content

Commit

Permalink
xunit/xunit#2811: Add SortedSet and ImmutableSortedSet overloads for …
Browse files Browse the repository at this point in the history
…Assert.Contains/DoesNotContain
  • Loading branch information
bradwilson committed Dec 7, 2023
1 parent 1dab747 commit 1f66b83
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions SetAsserts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ partial class Assert
HashSet<T> set) =>
Contains(expected, (ISet<T>)set);

/// <summary>
/// Verifies that the sorted hashset contains the given object.
/// </summary>
/// <typeparam name="T">The type of the object to be verified</typeparam>
/// <param name="expected">The object expected to be in the set</param>
/// <param name="set">The set to be inspected</param>
/// <exception cref="ContainsException">Thrown when the object is not present in the set</exception>
public static void Contains<T>(
T expected,
SortedSet<T> set) =>
Contains(expected, (ISet<T>)set);

#if XUNIT_IMMUTABLE_COLLECTIONS
/// <summary>
/// Verifies that the immutable hashset contains the given object.
Expand All @@ -89,6 +101,18 @@ partial class Assert
T expected,
ImmutableHashSet<T> set) =>
Contains(expected, (ISet<T>)set);

/// <summary>
/// Verifies that the immutable sorted hashset contains the given object.
/// </summary>
/// <typeparam name="T">The type of the object to be verified</typeparam>
/// <param name="expected">The object expected to be in the set</param>
/// <param name="set">The set to be inspected</param>
/// <exception cref="ContainsException">Thrown when the object is not present in the set</exception>
public static void Contains<T>(
T expected,
ImmutableSortedSet<T> set) =>
Contains(expected, (ISet<T>)set);
#endif

/// <summary>
Expand Down Expand Up @@ -145,6 +169,18 @@ partial class Assert
HashSet<T> set) =>
DoesNotContain(expected, (ISet<T>)set);

/// <summary>
/// Verifies that the sorted hashset does not contain the given item.
/// </summary>
/// <typeparam name="T">The type of the object to be verified</typeparam>
/// <param name="expected">The object expected to be in the set</param>
/// <param name="set">The set to be inspected</param>
/// <exception cref="ContainsException">Thrown when the object is not present in the set</exception>
public static void DoesNotContain<T>(
T expected,
SortedSet<T> set) =>
DoesNotContain(expected, (ISet<T>)set);

#if XUNIT_IMMUTABLE_COLLECTIONS
/// <summary>
/// Verifies that the immutable hashset does not contain the given item.
Expand All @@ -157,6 +193,18 @@ partial class Assert
T expected,
ImmutableHashSet<T> set) =>
DoesNotContain(expected, (ISet<T>)set);

/// <summary>
/// Verifies that the immutable sorted hashset does not contain the given item.
/// </summary>
/// <typeparam name="T">The type of the object to be verified</typeparam>
/// <param name="expected">The object expected to be in the set</param>
/// <param name="set">The set to be inspected</param>
/// <exception cref="ContainsException">Thrown when the object is not present in the set</exception>
public static void DoesNotContain<T>(
T expected,
ImmutableSortedSet<T> set) =>
DoesNotContain(expected, (ISet<T>)set);
#endif

/// <summary>
Expand Down

0 comments on commit 1f66b83

Please sign in to comment.