nunit: Bad error message if collections have different types

While framework supports checking equality of collections of different type, error message is not very informative in case of failure:

Expected is <System.String[1]>, actual is <System.Linq.Enumerable+SelectListIterator`2[NamespaceA.SomeType,System.String]>
  Values differ at index [0]

Possible options to fix: a) always log collections as items (e.g. “< 1,2,3… >”), ignoring type b) log actual and expected item where failed

(Personally I prefer option a) )

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 28 (28 by maintainers)

Most upvoted comments

Yeah, will take a look!

Ok, so seems like I haven’t provided all details (because I missed them myself). Such uninformative message occurs when there are non-collection arguments, and quantity differs:

        [Test]
        public void DifferentCollectionType()
        {
            var expected = new int[] { 1, 2, 3 };
            var actual = expected.Take(2);

            Assert.That(actual, Is.EqualTo(expected));
        }

---->

Expected is <System.Int32[3]>, actual is <System.Linq.Enumerable+ListPartition`1[System.Int32]>
  Values differ at index [2]

Would it make sense to log something like:

Values differ at index [2]
Expected: 3
Actual: (none)

?