No Free Time

Because my therapist says I need to let things out

MSTest still doesn’t assert array equality properly

Posted by Andrew Myhre on April 5, 2008

I ran into this issue today where asserting equality on two arrays always fails, even if the arrays really are equal:

Assert.Equals(new string[] {“value”}, new string[] {“value”}); // always fails

Evidently for arrays the Assert.Equals() method tests object identity, rather object equality, which is what you would expect. There is an Assert.AreSame() method which should test object identity, shouldn’t it?

I found this post from 2005 which notes the problem – I can’t believe they haven’t fixed it by now!

One Response to “MSTest still doesn’t assert array equality properly”

  1. EH said

    Hi, I came across the same problem today (am missing NUnit a bit)…

    MSTest has the following (at least in VS2008 SP1).

    CollectionAssert.AreEqual

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>