CollectionSubsetConstraint
CollectionSubsetConstraint is used to determine whether
one collection is a subset of another
using System.Collections;
namespace NUnit.Framework.Constraints
{
public class CollectionSubsetConstraint : CollectionItemsEqualConstraint
{
private IEnumerable expected;
public override string Description => "subset of " + MsgUtils.FormatValue(expected);
public CollectionSubsetConstraint(IEnumerable expected)
: base(expected)
{
this.expected = expected;
base.DisplayName = "SubsetOf";
}
protected override bool Matches(IEnumerable actual)
{
return Tally(expected).TryRemove(actual);
}
}
}