xUnit : Assert two List are equal?

前端 未结 4 1994
长发绾君心
长发绾君心 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:24

    With xUnit, should you want to cherry pick properties of each element to test you can use Assert.Collection.

    Assert.Collection(elements, 
      elem1 => Assert.Equal(expect1, elem1.SomeProperty),
      elem2 => { 
         Assert.Equal(expect2, elem2.SomeProperty);
         Assert.True(elem2.TrueProperty);
      });
    

    This tests the expected count and ensures that each action is verified.

提交回复
热议问题