MSTest框架有一个接受ICollections的CollectionAssert。我的方法返回一个IList。显然,列表不是集合..
有没有办法让我的IList成为ICollection?
发布于 2009-03-19 14:43:45
您可以对其调用ToArray()扩展方法-数组实现ICollection
编辑:另外,虽然List<T>实现了ICollection,但IList<T>只实现了不实现ICollection的ICollection<T>,所以如果您知道测试中的项是一个List<T>,那么您应该能够转换它……
发布于 2009-04-20 18:27:39
你可以发送一个列表
List<string> actual = new List<string>(){"1","2","3"};
List<string> expected = new List<string>(){"1","2","**EditCaseFalse**"};
CollectionAssert.AreEqual(actual,expected)我返回失败(第三个元素不匹配)。
https://stackoverflow.com/questions/662458
复制相似问题