public void SamePropertiesReturnTrue() { var class1 = new Class1{PropertyOne = "one", PropertyTwo = "two"}; var class2 = new Class1{PropertyOne = "one", PropertyTwo = "two"}; Assert.IsTrue(class1.Equals(class2)); }
public void DifferentPropertiesReturnFalse() { var class1 = new Class1{PropertyOne = "one", PropertyTwo = "two"}; var class2 = new Class1{PropertyOne = "one", PropertyTwo = "2"}; Assert.IsFalse(class1.Equals(class2)); }
public void DifferentTypesReturnFalse() { var class1 = new Class1 { PropertyOne = "one", PropertyTwo = "two" }; var class2 = new Class2(); // ReSharper disable SuspiciousTypeConversion.Global Assert.IsFalse(class1.Equals(class2)); // ReSharper restore SuspiciousTypeConversion.Global }
public void TheSameObjectsReturnTrue() { var class1 = new Class1(); // ReSharper disable EqualExpressionComparison Assert.IsTrue(class1.Equals(class1)); // ReSharper restore EqualExpressionComparison }
public void NullObjectReturnsFalse() { var class1 = new Class1(); Assert.IsFalse(class1.Equals(null)); }
protected bool Equals(Class1 other) { return string.Equals(PropertyOne, other.PropertyOne) && string.Equals(PropertyTwo, other.PropertyTwo); }