<PackageReference Include="NUnit" Version="3.0.0-alpha-5" />

CollectionEquivalentConstraint

CollectionEquivalentCOnstraint is used to determine whether two collections are equivalent.
using System.Collections; namespace NUnit.Framework.Constraints { public class CollectionEquivalentConstraint : CollectionItemsEqualConstraint { private readonly IEnumerable expected; public override string Description => "equivalent to " + MsgUtils.FormatValue(expected); public CollectionEquivalentConstraint(IEnumerable expected) : base(expected) { this.expected = expected; base.DisplayName = "Equivalent"; } protected override bool Matches(IEnumerable actual) { if (expected is ICollection && actual is ICollection && ((ICollection)actual).Count != ((ICollection)expected).Count) return false; CollectionTally collectionTally = Tally(expected); if (collectionTally.TryRemove(actual)) return collectionTally.Count == 0; return false; } } }