【发布时间】:2017-08-16 12:50:06
【问题描述】:
搭载this SO question...
这个测试是怎么失败的?
[TestMethod]
public void DummyTest() {
var expected = new List<List<string>>() {
new List<string>(){ "123456", "25.6", "15", "a" },
new List<string>(){ "123457", "3107450.82", "1", "bcdef" },
new List<string>(){ "123458", "0.01", "900000", "-fgehk" }
};
var actual = new List<List<string>>() {
new List<string>(){ "123456", "25.6", "15", "a" },
new List<string>(){ "123457", "3107450.82", "1", "bcdef" },
new List<string>(){ "123458", "0.01", "900000", "-fgehk" }
};
CollectionAssert.AreEqual(expected, actual);
}
顺便说一句,Assert.IsTrue(expected.SequenceEqual(actual)); 也失败了。
有没有更好的方法来测试集合的集合?
使用 .NET 4.6.1。
【问题讨论】:
-
补充一点,测试失败的结果信息是:“CollectionAssert.AreEqual failed. (Element at index 0 do not match.)”
标签: c# .net unit-testing