Public bug reported:
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
** Affects: nunit-3.0
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of NUnit
Core Developers, which is the registrant for NUnit Framework.
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:
New
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
_______________________________________________
Mailing list: https://launchpad.net/~nunit-core
Post to : [email protected]
Unsubscribe : https://launchpad.net/~nunit-core
More help : https://help.launchpad.net/ListHelp