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