public void ArmorEqualsAndHashCode() { Armor armor = new Armor(ArmorType.Unarmored, 5); //Using IsTrue/IsFalse to cover all paths (aren't covered, when using Equals) //Equal tests Assert.IsTrue(armor.Equals(armor)); Assert.AreEqual(armor.GetHashCode(), armor.GetHashCode()); object equal = new Armor(ArmorType.Unarmored, 5); Assert.IsTrue(armor.Equals(equal)); Assert.AreEqual(equal.GetHashCode(), armor.GetHashCode()); //Not equal tests Assert.IsFalse(armor.Equals(null)); object notEqual = new object(); Assert.IsFalse(armor.Equals(notEqual)); Assert.AreNotEqual(notEqual.GetHashCode(), armor.GetHashCode()); notEqual = new Armor(ArmorType.Medium, 5); Assert.IsFalse(armor.Equals(notEqual)); Assert.AreNotEqual(notEqual.GetHashCode(), armor.GetHashCode()); notEqual = new Armor(ArmorType.Unarmored, 3); Assert.IsFalse(armor.Equals(notEqual)); Assert.AreNotEqual(notEqual.GetHashCode(), armor.GetHashCode()); }