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

CollectionSubsetConstraint

CollectionSubsetConstraint is used to determine whether one collection is a subset of another
using System; using System.Collections; namespace NUnit.Framework.Constraints { public class CollectionSubsetConstraint : CollectionItemsEqualConstraint { private IEnumerable _expected; public override string DisplayName => "SubsetOf"; public override string Description => "subset of " + MsgUtils.FormatValue(_expected); public CollectionSubsetConstraint(IEnumerable expected) : base(expected) { _expected = expected; } protected override bool Matches(IEnumerable actual) { CollectionTally collectionTally = Tally(_expected); collectionTally.TryRemove(actual); return collectionTally.Result.ExtraItems.Count == 0; } public CollectionSubsetConstraint Using<TSubsetType, TSupersetType>(Func<TSubsetType, TSupersetType, bool> comparison) { Using(EqualityAdapter.For(comparison)); return this; } } }