NUnit comparing two lists

后端 未结 6 496
孤独总比滥情好
孤独总比滥情好 2021-01-01 10:16

OK so I\'m fairly new to unit testing and everything is going well until now. I\'m simplifying my problem here, but basically I have the following:

[Test]
pu         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 10:53

    I convert my comment to answer on request.

    Well, this fails because AreEqual uses reference comparison. In order to make it work you need value comparison(your own custom comparison).

    You can pretty much do that by implementing IEquatable interface. and keep in mind when you're implementing this interface you must override Object.Equals and Object.GetHashCode as well to get consistent results.

    .Net framework supports doing this without implementing IEquatable you need IEqualityComparer that should do the trick, but nunit should have a method which takes this as a overload. Am not certain about "nunit" though.

提交回复
热议问题