Quantcast
Viewing latest article 9
Browse Latest Browse All 1402

New Post: Confusion with OnlyContain usage

Here's a work-around for anyone who wants the old behaviour:
public static AndConstraint<GenericCollectionAssertions<T>> ReallyOnlyContain<T>(this GenericCollectionAssertions<T> itemsAssertion, Expression<Func<T, bool>> expectedItem)
{
    var notExpectedItem = Expression.Lambda<Func<T, bool>>(Expression.Not(expectedItem.Body), expectedItem.Parameters);
    return itemsAssertion.NotContain(notExpectedItem);
}

Viewing latest article 9
Browse Latest Browse All 1402

Trending Articles