public void GetHashCode_Should_Return_Desired_Results(double xFrom, double xTo, double yFrom, double yTo, bool expectedResult) { var x = new WeightRange(xFrom, xTo); var y = new WeightRange(yFrom, yTo); var xResult = x.GetHashCode(); var yResult = y.GetHashCode(); bool actualResult = xResult == yResult; Assert.Equal(expectedResult, actualResult); }
public override int GetHashCode() { unchecked { // ReSharper disable NonReadonlyMemberInGetHashCode var hashCode = WeightRange.GetHashCode(); hashCode = (hashCode * 397) ^ Kilograms.GetHashCode(); hashCode = (hashCode * 397) ^ IsMetric.GetHashCode(); // ReSharper restore NonReadonlyMemberInGetHashCode return(hashCode); } }