This fixes the problem of NUnit using an external comparer designed for a particular type inappropriately.
In addition, it allows use of generic comparers when comparing lists and other ienumerables. Multiple Using clauses may now appear, and will be used on the appropriate types. -- You received this bug notification because you are a member of NUnit Developers, which is subscribed to NUnit V2. https://bugs.launchpad.net/bugs/709062 Title: "System.ArgumentException : Cannot compare" when the element is a list Status in NUnit V2 Test Framework: Fix Committed Bug description: Relevant discussion can be found here. https://groups.google.com/forum/?pli=1#!topic/nunit- discuss/IgGiVyo3fKw This code throws me a System.ArgumentException : Cannot compare 2 exception. public class IntListEqualComparer: IEqualityComparer<List<int>> { public bool Equals(List<int> x, List<int> y) { return x.Count == y.Count; } public int GetHashCode(List<int> obj) { return obj.Count.GetHashCode(); } } [Test] public void IntListListTest() { var list1 = new List<int>() {2, 3}; var list2 = new List<int>() {2, 3}; var list11 = new List<List<int>>() {list1}; var list22 = new List<List<int>>() { list2 }; var comparer = new IntListEqualComparer(); Assert.That(list11, new CollectionEquivalentConstraint(list22).Using(comparer)); } It seems that Nunit can't compare if the elements are of the type List? Here's the complete stack trace: failed: System.ArgumentException : Cannot compare 2 at NUnit.Framework.Constraints.EqualityAdapter.EqualityComparerAdapter`1.ObjectsEqual(Object x, Object y) at NUnit.Framework.Constraints.NUnitEqualityComparer.ObjectsEqual(Object x, Object y) at NUnit.Framework.Constraints.NUnitEqualityComparer.CollectionsEqual(ICollection x, ICollection y) at NUnit.Framework.Constraints.NUnitEqualityComparer.ObjectsEqual(Object x, Object y) at NUnit.Framework.Constraints.CollectionItemsEqualConstraint.CollectionTally.ItemsEqual(Object expected, Object actual) at NUnit.Framework.Constraints.CollectionItemsEqualConstraint.CollectionTally.TryRemove(Object o) at NUnit.Framework.Constraints.CollectionItemsEqualConstraint.CollectionTally.TryRemove(IEnumerable c) at NUnit.Framework.Constraints.CollectionEquivalentConstraint.doMatch(IEnumerable actual) at NUnit.Framework.Constraints.CollectionConstraint.Matches(Object actual) To manage notifications about this bug go to: https://bugs.launchpad.net/nunitv2/+bug/709062/+subscriptions _______________________________________________ Mailing list: https://launchpad.net/~nunit-core Post to : [email protected] Unsubscribe : https://launchpad.net/~nunit-core More help : https://help.launchpad.net/ListHelp

