I have a unit test for a method which gets an object from a collection. This keeps failing and I cannot see why, so I have created a very simple test below to create 2 suppl
You compare 2 different instances of the Supplier type, that's why Assert fail.
If you want to Supplier are equals say (by their Id) you can override Equals method, here very over simpled example, :D.
public class Supplier
{
private int id;
private string name;
public int Id
{
get { return id; }
}
public string Name
{
get { return name; }
}
public bool Equals(Supplier other)
{
if(other == null) return false;
return other.id == id;
}
public override bool Equals(object obj)
{
if(obj == null) return false;
if (obj.GetType() != typeof (Supplier)) return false;
return Equals((Supplier) obj);
}
public override int GetHashCode()
{
return id;
}
}