我有两个字符串数组,当我检查它们时看起来是一样的。我使用了错误的Assert方法吗?
//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[]>.
答案 0 :(得分:2)
在集合上声明时,您需要CollectionAssert.AreEqual方法和CollectionAssert类:
CollectionAssert.AreEqual(expected, actual);