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
These answers are far too complicated for the issue. There are no overrides necessary to compare two Lists, and you do not need to break out multiple asserts. Microsoft uses the following class, CollectionAssert.
CollectionAssert.AreEqual(expectedList, actualList)
This works for Lists, Dictionaries, and whatever else implements ICollection interface.
The microsoft documentation is at the following location and details the various types of assertions which can be made on collections
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.collectionassert.aspx
However, as mentioned by @Bart, this does not work as expected on Lists of (complex) Objects, and the Equals method may still need to be overwritten for those cases.