コード例 #1
0
        public void Equals_BothAreNull_ShouldReturnTrue()
        {
            // Arrange
            BuildingInfoComparer comparer = new BuildingInfoComparer();

            // Act/Assert
            Assert.True(comparer.Equals(null, null));
        }
コード例 #2
0
        public void GetHashCode_ElementIsNull_ShouldNotThrow()
        {
            // Arrange
            BuildingInfoComparer comparer = new BuildingInfoComparer();

            // Act
            var hashCode = comparer.GetHashCode(null);

            // Assert
            Assert.Equal(-1, hashCode);
        }
コード例 #3
0
        public void Equals_OneIsNull_ShouldReturnFalse()
        {
            // Arrange
            var mockedElement = new Mock <IBuildingInfo>();

            mockedElement.SetupGet(x => x.Group).Returns(GROUP_FIRST);

            BuildingInfoComparer comparer = new BuildingInfoComparer();

            // Act/Assert
            Assert.False(comparer.Equals(mockedElement.Object, null));
            Assert.False(comparer.Equals(null, mockedElement.Object));
        }
コード例 #4
0
        public void Equals_DifferentGroup_ShouldReturnFalse()
        {
            // Arrange
            var mockedElement1 = new Mock <IBuildingInfo>();

            mockedElement1.SetupGet(x => x.Group).Returns(GROUP_FIRST);

            var mockedElement2 = new Mock <IBuildingInfo>();

            mockedElement2.SetupGet(x => x.Group).Returns(GROUP_SECOND);

            BuildingInfoComparer comparer = new BuildingInfoComparer();

            // Act/Assert
            Assert.False(comparer.Equals(mockedElement1.Object, mockedElement2.Object));
        }
コード例 #5
0
        public void GetHashCode_BothEqual_ShouldBeEqual()
        {
            // Arrange
            var mockedElement1 = new Mock <IBuildingInfo>();

            mockedElement1.SetupGet(x => x.Group).Returns(GROUP_FIRST);

            var mockedElement2 = new Mock <IBuildingInfo>();

            mockedElement2.SetupGet(x => x.Group).Returns(GROUP_FIRST);

            BuildingInfoComparer comparer = new BuildingInfoComparer();

            // Act
            var hashCode1 = comparer.GetHashCode(mockedElement1.Object);
            var hashCode2 = comparer.GetHashCode(mockedElement2.Object);

            // Assert
            Assert.Equal(hashCode1, hashCode2);
        }