示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }