Beispiel #1
0
        public void GetHashCode_DifferentValues_DifferentHash()
        {
            // Arrange
            var fooA = new TestSettings1
            {
                IntProperty   = 123,
                StringPropert = "ms"
            };
            var fooB = new TestSettings1
            {
                IntProperty   = 321,
                StringPropert = "sdfe"
            };

            // Act
            var hashA = fooA.GetHashCode();
            var hashB = fooB.GetHashCode();

            // Assert
            Assert.AreNotEqual(hashA, hashB);
        }
Beispiel #2
0
        public void Equals_DifferentValues_False()
        {
            // Arrange
            var fooA = new TestSettings1
            {
                IntProperty   = 123,
                StringPropert = "ms"
            };
            var fooB = new TestSettings1
            {
                IntProperty   = 321,
                StringPropert = "sdfe"
            };

            // Act
            var equalsAB = fooA.Equals(fooB);
            var equalsBA = fooB.Equals(fooA);

            // Assert
            Assert.IsFalse(equalsAB);
            Assert.IsFalse(equalsBA);
        }
Beispiel #3
0
        public void GetHashCode_DifferentClasses_DifferentHash()
        {
            // Arrange
            var intValue = 317;
            var strValue = "s";
            var fooA     = new TestSettings1
            {
                IntProperty   = intValue,
                StringPropert = strValue
            };
            var fooB = new TestSettings2
            {
                IntProperty   = intValue,
                StringPropert = strValue
            };

            // Act
            var hashA = fooA.GetHashCode();
            var hashB = fooB.GetHashCode();

            // Assert
            Assert.AreNotEqual(hashA, hashB);
        }
Beispiel #4
0
        public void Equals_DifferentClasses_False()
        {
            // Arrange
            var intValue = 317;
            var strValue = "s";
            var fooA     = new TestSettings1
            {
                IntProperty   = intValue,
                StringPropert = strValue
            };
            var fooB = new TestSettings2
            {
                IntProperty   = intValue,
                StringPropert = strValue
            };

            // Act
            var equalsAB = fooA.Equals(fooB);
            var equalsBA = fooB.Equals(fooA);

            // Assert
            Assert.IsFalse(equalsAB);
            Assert.IsFalse(equalsBA);
        }
Beispiel #5
0
        public void Equals_SameValues_True()
        {
            // Arrange
            var intValue = 317;
            var strValue = "s";
            var fooA     = new TestSettings1
            {
                IntProperty   = intValue,
                StringPropert = strValue
            };
            var fooB = new TestSettings1
            {
                IntProperty   = intValue,
                StringPropert = strValue
            };

            // Act
            var equalsAB = fooA.Equals(fooB);
            var equalsBA = fooB.Equals(fooA);

            // Assert
            Assert.IsTrue(equalsAB);
            Assert.IsTrue(equalsBA);
        }