由网友(心已麻木i)分享简介:除了通过要素之一步进接一个,我怎么比较平等的字符串两个列表(在.NET 3.0):Other than stepping through the elements one by one, how do I compare two lists of strings for equality (in .NET 3.0):...
除了通过要素之一步进接一个,我怎么比较平等的字符串两个列表(在.NET 3.0):
Other than stepping through the elements one by one, how do I compare two lists of strings for equality (in .NET 3.0):
这将失败:
// Expected result.
List<string> expected = new List<string>();
expected.Add( "a" );
expected.Add( "b" );
expected.Add( "c" );
// Actual result
actual = new List<string>();
actual.Add( "a" );
actual.Add( "b" );
actual.Add( "c" );
// Verdict
Assert.IsTrue( actual == expected );
在此先感谢
推荐答案
许多测试框架提供了一个CollectionAssert类:
Many test frameworks offer a CollectionAssert class:
CollectionAssert.AreEqual(expected, actual);
例如MS测试
相关推荐
最新文章