Reputation: 3040
I wonder if there is a way to compare two lists of different types. I found this method:
public AndConstraint<TAssertions> Equal(IEnumerable<T> expectation, Func<T, T, bool> predicate, string because = "", params object[] reasonArgs)
{
this.AssertSubjectEquality<T>((IEnumerable) expectation, predicate, because, reasonArgs);
return new AndConstraint<TAssertions>((TAssertions) this);
}
I am looking for something like:
public AndConstraint<TAssertions> Equal<U>(IEnumerable<T> expectation, Func<T, U, bool> predicate, string because = "", params object[] reasonArgs)
{
this.AssertSubjectEquality<T,U>((IEnumerable) expectation, predicate, because, reasonArgs);
return new AndConstraint<TAssertions>((TAssertions) this);
}
I tried to make an extension method but method AssertSubjectEquality is protected and does not support a second type.
Upvotes: 0
Views: 857
Reputation: 8889
You can't do that without copying the AssertSubjectEquality
and AssertCollectionsHaveSameCount
methods of the CollectionAssertions
class along with it.
Instead, I would suggest you fork the repository and send me a Pull Request in which you change the generic parameters of those two methods from <T>
to <T, U>
and add your method to the GenericCollectionAssertions
. I'll make it part of v3.3.
Upvotes: 1