Using Assert to compare two objects
- by baron
Hi everyone,
Writing test cases for my project, one test I need is to test deletion. This may not exactly be the right way to go about it, but I've stumbled upon something which isn't making sense to me.
Code is like this:
[Test]
private void DeleteFruit()
{
BuildTestData();
var f1 = new Fruit("Banana",1,1.5);
var f2 = new Fruit("Apple",1,1.5);
fm.DeleteFruit(f1,listOfFruit);
Assert.That(listOfFruit[1] == f2);
}
Now the fruit object I create line 5 is the object that I know should be in that position (with this specific dataset) after f1 is deleted.
Also if I sit and debug, and manually compare objects listOfFruit[1] and f2 they are the same. But that Assert line fails. What gives?