コード例 #1
0
        public void TestOverrideGetHashCode()
        {
            Student student1 = new Student("Morten", "Et eller andet sted", 3, Gender.Male);
            Student student2 = new Student("Lucas", "Et andet sted", 3, Gender.Male);
            Student student3 = new Student("Morten", "Et eller andet sted", 3, Gender.Male);


            Assert.IsFalse(student1.GetHashCode() == student2.GetHashCode());
            Assert.IsFalse(student2.GetHashCode() == student1.GetHashCode());
            Assert.IsTrue(student1.GetHashCode() == student3.GetHashCode());
        }
コード例 #2
0
        public void StudentGetHashCodeTest()
        {
            Student student  = new Student("Alex", "Pmi-32", "KlakovichLM");
            int     expected = 579429062;
            int     actual   = student.GetHashCode();

            Assert.AreEqual(actual, expected);
        }