← Back to team overview

nunit-core team mailing list archive

[Bug 708173] Re: NUnit's logic for comparing arrays - use Comparer<T[]> if it is provided.

 

** Changed in: nunit-3.0
       Status: New => Triaged

** Tags added: feature framework

** Changed in: nunit-3.0
   Importance: Undecided => High

** Changed in: nunit-3.0
     Assignee: (unassigned) => Charlie Poole (charlie.poole)

** Changed in: nunit-3.0
    Milestone: None => 2.9.6

-- 
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:
  Triaged

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