2

I have 2 string arrays that appear to be the same when I inspect them. Am I using the wrong Assert method?

//Arrange
string[] expected = new[] { "Widget A", "Widget B" };
string[] actual;
//Act
actual = api.GetIncidents(credentials);
//Assert
Assert.AreEqual(expected, actual);

Assert.AreEqual failed. Expected:<System.String[]>. Actual:<System.String[]>.
2
  • Which unit testing framework are you using? Commented Mar 4, 2013 at 20:32
  • Microsoft Test Framework in VS2008 SP1 Commented Mar 4, 2013 at 20:33

1 Answer 1

2

You need the CollectionAssert.AreEqual method and generally the CollectionAssert class when asserting on collections:

CollectionAssert.AreEqual(expected, actual);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.