我目前正在学习如何使用单元测试,并且我已经创建了包含3个动物对象的实际列表和预期列表。问题是如何进行断言以检查这些列表是否相等?我尝试过CollectionAssert.AreEqual和Assert.AreEqual,但都没有成功。任何帮助将不胜感激。
测试方法:
[TestMethod]
public void createAnimalsTest2()
{
animalHandler animalHandler = new animalHandler();
// arrange
List<Animal> expected = new List<Animal>();
Animal dog = new Dog("",0);
Animal cat = new Cat("",0);
Animal mouse = new Mouse("",0);
expected.Add(dog);
expected.Add(cat);
expected.Add(mouse);
//actual
List<Animal> actual = animalHandler.createAnimals("","","",0,0,0);
//assert
//this is the line that does not evaluate as true
Assert.Equals(expected ,actual);
}