public void Equals_SameInstance_ReturnTrue() { // Setup var comparer = new StructureIdEqualityComparer(); var structure = new TestStructure(); // Call bool areEqual = comparer.Equals(structure, structure); // Assert Assert.IsTrue(areEqual); }
public void Equals_SameId_ReturnTrue(TestStructure secondStructure) { // Setup var comparer = new StructureIdEqualityComparer(); var firstStructure = new TestStructure(); // Call bool firstEqualsSecond = comparer.Equals(firstStructure, secondStructure); bool secondEqualsFirst = comparer.Equals(secondStructure, firstStructure); // Assert Assert.IsTrue(firstEqualsSecond); Assert.IsTrue(secondEqualsFirst); }
public void GetHashCode_EqualStructures_ReturnsSameHashCode() { // Setup var comparer = new StructureIdEqualityComparer(); var structureOne = new TestStructure(); var structureTwo = new TestStructure(); // Call int hashCodeOne = comparer.GetHashCode(structureOne); int hashCodeTwo = comparer.GetHashCode(structureTwo); // Assert Assert.AreEqual(hashCodeOne, hashCodeTwo); }
public void Equals_UnequalInstance_ReturnFalse() { // Setup var comparer = new StructureIdEqualityComparer(); var firstStructure = new TestStructure("id"); var secondStructure = new TestStructure("other id"); // Call bool firstEqualsSecond = comparer.Equals(firstStructure, secondStructure); bool secondEqualsFirst = comparer.Equals(secondStructure, firstStructure); // Assert Assert.IsFalse(firstEqualsSecond); Assert.IsFalse(secondEqualsFirst); }