public void GetHashCode_WhenConstructedWithTheSameCharacters_ReturnsTheSameValue(char min, char max) { var subjectA = new CharacterRange(min, max); var subjectB = new CharacterRange(min, max); Assert.That(subjectA.GetHashCode(), Is.EqualTo(subjectB.GetHashCode())); }
public void Equals_Valid_ReturnsExpected(CharacterRange range, object other, bool expected) { Assert.Equal(expected, range.Equals(other)); if (other is CharacterRange otherRange) { Assert.Equal(expected, range == otherRange); Assert.Equal(!expected, range != otherRange); Assert.Equal(expected, range.GetHashCode().Equals(otherRange.GetHashCode())); } }
int ComputeHashCode() { return(HashCode.Compute( CharacterRange.GetHashCode(), CharacterClass.GetHashCode())); }