2

我有 2 个字符串数组,当我检查它们时它们看起来是一样的。我使用了错误的断言方法吗?

//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[]>.
4

1 回答 1

2

在对集合进行断言时,您需要CollectionAssert.AreEqual方法和通常的CollectionAssert类:

CollectionAssert.AreEqual(expected, actual);
于 2013-03-04T20:34:33.583 回答