public void Customer_RefEquality() { Customer c1 = new Customer("Oliver", "Lassen"); Customer c2 = new Customer("Oliver", "Lassen"); Assert.False(c1 == c2); }
public void Customer_CustomStructralEquality_DifferSurname() { Customer c1 = new Customer("Oliver", "Lassen"); Customer c2 = new Customer("Oliver", "Lassen", "Leo"); Assert.True(c1.Equals(c2, CustomerEqualityComparer.Default)); }
public static void Main(string[] args) { Customer c1 = new Customer("Oliver", "Lassen"); Customer c2 = new Customer("Oliver", "Lassen"); Console.WriteLine("Reference equality: {0} (Should not be equal)", c1 == c2); Console.WriteLine("x.Equals(): {0} (Should not be equal)", c1.Equals(c2)); }
public override int GetHashCode(Customer obj) { return obj.FirstName.GetHashCode() * 31 + obj.LastName.GetHashCode() * 31; }
public override bool Equals(Customer x, Customer y) { return (x.FirstName == y.FirstName) && (x.LastName == y.LastName); }
public void Customer_SelfRefEquality() { Customer c1 = new Customer("Oliver", "Lassen"); Assert.True(c1 == c1); }