public void GetHashCode_GivenTwoNotEqualsObject_MethodReturDifferentHashCodes() { var a = new ReportColumn() { Title = "ColumnA", // <--- SqlValueExpression = "Exp" }; var b = new ReportColumn() { Title = "ColumnB", // <--- SqlValueExpression = "Exp" }; Assert.That(a.GetHashCode(), Is.Not.EqualTo(b.GetHashCode())); a = new ReportColumn() { Title = "ColumnA", SqlValueExpression = "ExpA" // <--- }; b = new ReportColumn() { Title = "ColumnA", SqlValueExpression = "ExpB" // <--- }; Assert.That(a.GetHashCode(), Is.Not.EqualTo(b.GetHashCode())); }
public void Equals_Symmetric() { var x = new ReportColumn() { Title = "Column A", SqlValueExpression = "select 1" }; var y = new ReportColumn() { Title = "Column A", SqlValueExpression = "select 1" }; Assert.IsTrue(x.Equals(y) && y.Equals(x)); Assert.IsTrue(x.GetHashCode() == y.GetHashCode()); }
public void GetHashCode_GivenTwoEqualsObject_MethodReturEqualHashCodes() { var a = new ReportColumn() { Title = "ColumnA", SqlValueExpression = "Exp" }; var b = new ReportColumn() { Title = "ColumnA", SqlValueExpression = "Exp" }; Assert.That(a.GetHashCode(), Is.EqualTo(b.GetHashCode())); }