public void SameObjectHashCodeAreSame()
        {
            var value1 = new ComplexObject
            {
                SimpleProperty = "A",
                ListProperty   = new List <string> {
                    "A", "B", "C"
                }
            };
            var value2 = new ComplexObject
            {
                SimpleProperty = "A",
                ListProperty   = new List <string> {
                    "A", "B", "C"
                }
            };
            var code1 = value1.GetHashCode();
            var code2 = value2.GetHashCode();

            Assert.Equal(code1, code2);
            Assert.Equal(value1, value2);
        }
Beispiel #2
0
        public void ObjectsWithTheSameValuesShouldBeEqual()
        {
            var value1 = new ComplexObject
            {
                SimpleProperty = "A",
                ListProperty   = new List <string> {
                    "A", "B", "C"
                }
            };
            var value2 = new ComplexObject
            {
                SimpleProperty = "A",
                ListProperty   = new List <string> {
                    "A", "B", "C"
                }
            };
            var code1 = value1.GetHashCode();
            var code2 = value2.GetHashCode();

            Assert.Equal(code1, code2);
            Assert.Equal(value1, value2);
        }