Exemplo n.º 1
0
        public void TestEquals()
        {
            IntList list = new IntList();

            Assert.AreEqual(list, list);
            Assert.IsTrue(!list.Equals(null));
            IntList list2 = new IntList(200);

            Assert.IsTrue(list.Equals(list2));//Assert.AreEqual(list, list2);
            Assert.IsTrue(list2.Equals(list));//Assert.AreEqual(list2, list);
            Assert.AreEqual(list.GetHashCode(), list2.GetHashCode());
            list.Add(0);
            list.Add(1);
            list2.Add(1);
            list2.Add(0);
            Assert.IsTrue(!list.Equals(list2));
            list2.RemoveValue(1);
            list2.Add(1);
            Assert.IsTrue(list.Equals(list2));//Assert.AreEqual(list, list2);
            Assert.IsTrue(list2.Equals(list));//Assert.AreEqual(list2, list);
            list2.Add(2);
            Assert.IsTrue(!list.Equals(list2));
            Assert.IsTrue(!list2.Equals(list));
        }