The following method fails:
[TestMethod]
public void VerifyArrays()
{
int[] actualArray = { 1, 3, 7 };
Assert.AreEqual(new int[] { 1, 3, 7 }, actualArray);
}
How do I make it pass without iterating over the collection?
The following method fails:
[TestMethod]
public void VerifyArrays()
{
int[] actualArray = { 1, 3, 7 };
Assert.AreEqual(new int[] { 1, 3, 7 }, actualArray);
}
How do I make it pass without iterating over the collection?
Microsoft has provided a helper class CollectionAssert
.
[TestMethod]
public void VerifyArrays()
{
int[] actualArray = { 1, 3, 7 };
CollectionAssert.AreEqual(new int[] { 1, 3, 7 }, actualArray);
}
You can use the Enumerable.SequenceEqual()
method.
[TestMethod]
public void VerifyArrays()
{
int[] actualArray = { 1, 3, 7 };
int[] expectedArray = { 1, 3, 7 };
Assert.IsTrue(actualArray.SequenceEqual(expectedArray));
}