Exemplo n.º 1
0
        public void Common()
        {
            var obj  = new ClassOne();
            var code = obj.GetHashCode();

            obj = new ClassOne();
            var code2 = obj.GetHashCode();

            Assert.AreEqual(code, code2);

            obj = new ClassOne("哈哈");
            var code3 = obj.GetHashCode();

            var obj1  = new ClassOne("嘿嘿");
            var code4 = obj1.GetHashCode();

            Assert.AreNotEqual(code3, code4);

            var obj2  = new ClassOne("嘿嘿");
            var code5 = obj2.GetHashCode();

            Assert.AreEqual(code4, code5);

            Assert.IsTrue(obj1.Equals(obj2));
            Assert.IsFalse(obj.Equals(obj2));
        }