xUnit : Assert two List are equal?

前端 未结 4 1997
长发绾君心
长发绾君心 2020-12-05 01:33

I\'m new to TDD and xUnit so I want to test my method that looks something like:

List DeleteElements(this List a, List b         


        
4条回答
  •  情书的邮戳
    2020-12-05 02:05

    xUnit.Net recognizes collections so you just need to do

    Assert.Equal(expected, actual); // Order is important
    

    You can see other available collection assertions in CollectionAsserts.cs

    For NUnit library collection comparison methods are

    CollectionAssert.AreEqual(IEnumerable, IEnumerable) // For sequences, order matters
    

    and

    CollectionAssert.AreEquivalent(IEnumerable, IEnumerable) // For sets, order doesn't matter
    

    More details here: CollectionAssert

    MbUnit also has collection assertions similar to NUnit: Assert.Collections.cs

提交回复
热议问题