nunit-core team mailing list archive
-
nunit-core team
-
Mailing list archive
-
Message #03600
[Bug 708173] Re: NUnit's logic for comparing arrays - use Comparer<T[]> if it is provided.
** Changed in: nunit-3.0
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
https://bugs.launchpad.net/bugs/708173
Title:
NUnit's logic for comparing arrays - use Comparer<T[]> if it is
provided.
Status in NUnit Test Framework:
Fix Released
Status in NUnit V2 Test Framework:
Fix Released
Bug description:
In the following code snippet, NUnit uses passed comparer as elements'
comparer, which prevents us from treating array types just like any
other data types in unit tests. The workaround is to check for
equality in the following way - Assert.AreEqual(0,
comparer.Compare(expected, actual))).
[TestFixture]
public class NUnitFeatures
{
[Test]
public void CustomArrayComparison()
{
Assert.That(new[] { 1 }, Is.EqualTo(new[] { 1 }).Using(new IntArrayComparer()));
}
class IntArrayComparer : IComparer<int[]>
{
public int Compare(int[] x, int[] y) { return 0; } // just a stub
}
}
Google groups discussion:
http://groups.google.com/group/nunit-discuss/browse_thread/thread/792d9afbe01f7892
To manage notifications about this bug go to:
https://bugs.launchpad.net/nunit-3.0/+bug/708173/+subscriptions
References