Comparing Two objects using Assert.AreEqual()

后端 未结 5 1054
眼角桃花
眼角桃花 2020-12-30 20:24

I \'m writing test cases for the first time in visual studio c# i have a method that returns a list of objects and i want to compare it with another list of objects by using

5条回答
  •  死守一世寂寞
    2020-12-30 20:49

    Assert.AreEqual() compares references. Usually when comparing lists I compare the count of the items and than some properties of one exact item in the list or directly the item in the list (but again it is the reference).

    If you want to compare objects by content than you would have to implement some recursive Object Comparer, but I don't think it is appropriate for Unit Tests, because you want them to run always as fast as possible.

提交回复
热议问题