<PackageReference Include="NUnit" Version="4.1.0" />

CollectionAssert

public abstract class CollectionAssert : AssertBase
A set of Assert methods operating on one or more collections
using NUnit.Framework.Constraints; using System; using System.Collections; using System.ComponentModel; using System.Runtime.CompilerServices; namespace NUnit.Framework.Legacy { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public abstract class CollectionAssert : AssertBase { [EditorBrowsable(EditorBrowsableState.Never)] public new static bool Equals(object a, object b) { throw new InvalidOperationException("CollectionAssert.Equals should not be used. Use CollectionAssert.AreEqual instead."); } public new static void ReferenceEquals(object a, object b) { throw new InvalidOperationException("CollectionAssert.ReferenceEquals should not be used."); } public static void AllItemsAreInstancesOfType(IEnumerable collection, Type expectedType) { AllItemsAreInstancesOfType(collection, expectedType, string.Empty, null); } public static void AllItemsAreInstancesOfType(IEnumerable collection, Type expectedType, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(collection, Is.All.InstanceOf(expectedType), () => AssertBase.ConvertMessageWithArgs(message, args), "collection", "Is.All.InstanceOf(expectedType)"); } public static void AllItemsAreNotNull(IEnumerable collection) { AllItemsAreNotNull(collection, string.Empty, null); } public static void AllItemsAreNotNull(IEnumerable collection, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(collection, Is.All.Not.Null, () => AssertBase.ConvertMessageWithArgs(message, args), "collection", "Is.All.Not.Null"); } public static void AllItemsAreUnique(IEnumerable collection) { AllItemsAreUnique(collection, string.Empty, null); } public static void AllItemsAreUnique(IEnumerable collection, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(collection, Is.Unique, () => AssertBase.ConvertMessageWithArgs(message, args), "collection", "Is.Unique"); } public static void AreEqual(IEnumerable expected, IEnumerable actual) { AreEqual(expected, actual, string.Empty, null); } public static void AreEqual(IEnumerable expected, IEnumerable actual, IComparer comparer) { AreEqual(expected, actual, comparer, string.Empty, null); } public static void AreEqual(IEnumerable expected, IEnumerable actual, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(actual, Is.EqualTo(expected).AsCollection, () => AssertBase.ConvertMessageWithArgs(message, args), "actual", "Is.EqualTo(expected).AsCollection"); } public static void AreEqual(IEnumerable expected, IEnumerable actual, IComparer comparer, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(actual, Is.EqualTo(expected).Using(comparer), () => AssertBase.ConvertMessageWithArgs(message, args), "actual", "Is.EqualTo(expected).Using(comparer)"); } public static void AreEquivalent(IEnumerable expected, IEnumerable actual) { AreEquivalent(expected, actual, string.Empty, null); } public static void AreEquivalent(IEnumerable expected, IEnumerable actual, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(actual, Is.EquivalentTo(expected), () => AssertBase.ConvertMessageWithArgs(message, args), "actual", "Is.EquivalentTo(expected)"); } public static void AreNotEqual(IEnumerable expected, IEnumerable actual) { AreNotEqual(expected, actual, string.Empty, null); } public static void AreNotEqual(IEnumerable expected, IEnumerable actual, IComparer comparer) { AreNotEqual(expected, actual, comparer, string.Empty, null); } public static void AreNotEqual(IEnumerable expected, IEnumerable actual, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(actual, Is.Not.EqualTo(expected).AsCollection, () => AssertBase.ConvertMessageWithArgs(message, args), "actual", "Is.Not.EqualTo(expected).AsCollection"); } public static void AreNotEqual(IEnumerable expected, IEnumerable actual, IComparer comparer, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(actual, Is.Not.EqualTo(expected).Using(comparer), () => AssertBase.ConvertMessageWithArgs(message, args), "actual", "Is.Not.EqualTo(expected).Using(comparer)"); } public static void AreNotEquivalent(IEnumerable expected, IEnumerable actual) { AreNotEquivalent(expected, actual, string.Empty, null); } public static void AreNotEquivalent(IEnumerable expected, IEnumerable actual, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(actual, Is.Not.EquivalentTo(expected), () => AssertBase.ConvertMessageWithArgs(message, args), "actual", "Is.Not.EquivalentTo(expected)"); } public static void Contains(IEnumerable collection, [System.Runtime.CompilerServices.Nullable(2)] object actual) { Contains(collection, actual, string.Empty, null); } public static void Contains(IEnumerable collection, [System.Runtime.CompilerServices.Nullable(2)] object actual, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(collection, Has.Member(actual), () => AssertBase.ConvertMessageWithArgs(message, args), "collection", "Has.Member(actual)"); } public static void DoesNotContain(IEnumerable collection, object actual) { DoesNotContain(collection, actual, string.Empty, null); } public static void DoesNotContain(IEnumerable collection, object actual, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(collection, Has.No.Member(actual), () => AssertBase.ConvertMessageWithArgs(message, args), "collection", "Has.No.Member(actual)"); } public static void IsNotSubsetOf(IEnumerable subset, IEnumerable superset) { IsNotSubsetOf(subset, superset, string.Empty, null); } public static void IsNotSubsetOf(IEnumerable subset, IEnumerable superset, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(subset, Is.Not.SubsetOf(superset), () => AssertBase.ConvertMessageWithArgs(message, args), "subset", "Is.Not.SubsetOf(superset)"); } public static void IsSubsetOf(IEnumerable subset, IEnumerable superset) { IsSubsetOf(subset, superset, string.Empty, null); } public static void IsSubsetOf(IEnumerable subset, IEnumerable superset, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(subset, Is.SubsetOf(superset), () => AssertBase.ConvertMessageWithArgs(message, args), "subset", "Is.SubsetOf(superset)"); } public static void IsNotSupersetOf(IEnumerable superset, IEnumerable subset) { IsNotSupersetOf(superset, subset, string.Empty, null); } public static void IsNotSupersetOf(IEnumerable superset, IEnumerable subset, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(superset, Is.Not.SupersetOf(subset), () => AssertBase.ConvertMessageWithArgs(message, args), "superset", "Is.Not.SupersetOf(subset)"); } public static void IsSupersetOf(IEnumerable superset, IEnumerable subset) { IsSupersetOf(superset, subset, string.Empty, null); } public static void IsSupersetOf(IEnumerable superset, IEnumerable subset, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(superset, Is.SupersetOf(subset), () => AssertBase.ConvertMessageWithArgs(message, args), "superset", "Is.SupersetOf(subset)"); } public static void IsEmpty(IEnumerable collection, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(collection, new EmptyCollectionConstraint(), () => AssertBase.ConvertMessageWithArgs(message, args), "collection", "new EmptyCollectionConstraint()"); } public static void IsEmpty(IEnumerable collection) { IsEmpty(collection, string.Empty, null); } public static void IsNotEmpty(IEnumerable collection, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(collection, new NotConstraint(new EmptyCollectionConstraint()), () => AssertBase.ConvertMessageWithArgs(message, args), "collection", "new NotConstraint(new EmptyCollectionConstraint())"); } public static void IsNotEmpty(IEnumerable collection) { IsNotEmpty(collection, string.Empty, null); } public static void IsOrdered(IEnumerable collection, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(collection, Is.Ordered, () => AssertBase.ConvertMessageWithArgs(message, args), "collection", "Is.Ordered"); } public static void IsOrdered(IEnumerable collection) { IsOrdered(collection, string.Empty, null); } public static void IsOrdered(IEnumerable collection, IComparer comparer, string message, [System.Runtime.CompilerServices.Nullable(2)] params object[] args) { Assert.That(collection, Is.Ordered.Using(comparer), () => AssertBase.ConvertMessageWithArgs(message, args), "collection", "Is.Ordered.Using(comparer)"); } public static void IsOrdered(IEnumerable collection, IComparer comparer) { IsOrdered(collection, comparer, string.Empty, null); } } }