I'm adding unit testing to my (Visual Basic) project. I'm using the testing tools in Visual Studio (2010 Premium). In a couple of test I would like to make sure that my class is equal to the expected value of the class with Assert.AreEqual. But this doesn't work out开发者_如何转开发 of the box.
What is best to do, override the Equals Method implement the IEqualityComparer Interface, or ...?
Assert is a static class, you won't be able to extend the object, or add an extension.
You have 3 choices
Add another Assert static equalivalent class to your project and implement AreEqual taking in IEqualityComparer,
Override the Equals method ( GetHashCode, == and != operators as well )
Use Assert.IsTrue and evaluate using an implementation of IEqualityComparer
Cheers...
精彩评论