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!
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