开发者

Comparing two lists with MSpec

开发者 https://www.devze.com 2023-01-22 21:37 出处:网络
Which method should I use to assert that two lists contai开发者_如何学Pythonns the same objects with MSpec?You could use the ShouldContainOnly(IEnumerable<T>) extension method.

Which method should I use to assert that two lists contai开发者_如何学Pythonns the same objects with MSpec?


You could use the ShouldContainOnly(IEnumerable<T>) extension method.

So if you have 2 lists, listA and listB use:

listA.ShouldContainOnly(listB)


If the order of the items in the list doesn't matter, you would use

listA.ShouldContainOnly(listB); // both lists must have exactly the same items
listA.ShouldContain(listB);     // listA must at least contain the items of listB

If the order of the items matters, you can use

listA.ShouldEqual(listB);
0

精彩评论

暂无评论...
验证码 换一张
取 消