public void EqualsReturnsTrueWhenEqual() { ReplacerEntry entry1 = new ReplacerEntry("o", "m"); ReplacerEntry entry2 = new ReplacerEntry("o", "m"); Assert.That(entry1.Equals(entry2), Is.True); }
public void EqualsReturnsFalseWhenDifferent() { ReplacerEntry entry1 = new ReplacerEntry("o", "m"); ReplacerEntry entry2 = new ReplacerEntry("o", "t"); Assert.That(entry1.Equals(entry2), Is.False); ReplacerEntry entry3 = new ReplacerEntry("t", "m"); Assert.That(entry1.Equals(entry3), Is.False); }
public void HashCodeDependsOnFields() { ReplacerEntry entry1 = new ReplacerEntry("o", "m"); ReplacerEntry entry2 = new ReplacerEntry("o", "t"); ReplacerEntry entry3 = new ReplacerEntry("t", "m"); ReplacerEntry entry4 = new ReplacerEntry("o", "m"); Assert.That(entry1.GetHashCode(), Is.EqualTo(entry4.GetHashCode())); Assert.That(entry1.GetHashCode(), Is.Not.EqualTo(entry2.GetHashCode())); Assert.That(entry1.GetHashCode(), Is.Not.EqualTo(entry3.GetHashCode())); }
public void EqualityIsLikeEquals() { ReplacerEntry entry1 = new ReplacerEntry("o", "m"); ReplacerEntry entry2 = new ReplacerEntry("o", "t"); ReplacerEntry entry3 = new ReplacerEntry("t", "m"); ReplacerEntry entry4 = new ReplacerEntry("o", "m"); Assert.That(entry1 == entry4, Is.True); Assert.That(entry1 != entry4, Is.False); Assert.That(entry1 == entry2, Is.False); Assert.That(entry1 != entry2, Is.True); Assert.That(entry1 == entry3, Is.False); Assert.That(entry1 != entry3, Is.True); }
public void EqualsObjReturnsFalseWhenDifferentType() { ReplacerEntry entry1 = new ReplacerEntry("o", "m"); Assert.That(entry1.Equals(5), Is.False); }