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
Assert.AreEqual in xUnit on .NET will check if the objects are identical however object identity is different from value equallity it would seem you are looking for value equality. Ie. "Are the objects in my list of the same value?" which is why it "fails" the two lists are not identical even though the values of each object in each list might represent the same value.
Usually in a testing effort it should be enough to test the count of a collection and key elements.
var count = listA.Count;
Assert.AreEqual(count,listB.Count);
Assert.AreEqual(listA.First(),listB.first());
Assert.AreEqual(listA.Last(),listB.Last());
Assert.AreEqual(listA[count/2],listB[count/2]);
The last test doesn't have to be at the middle element and is simply meant to test an element in the list the only reason why it's not a random element is because you would want to be able to reproduce your test results.