locked
What is the best way to compare constructed classes in unit testing? RRS feed

  • Question

  • I'm working with several classes built by my company for our projects, and I am trying to determine the best way to compare two instances of these objects during unit testing. Should I override the Equals method on each object so I can call the Assert.AreEqual or should I create extension methods in my unit testing project to compare the objects?
    Monday, April 25, 2011 1:54 PM

Answers

  • Hi Graham,

    The equality algorithm should be specific for the business requirement for your classes. If they do not work with  Assert.AreEqual then you should have separate comparison utilities defined to comapre them.

     

    Thanks,

    Abhishek [MSFT]

    Monday, May 9, 2011 4:59 PM