Esempio n. 1
0
        public void ArrayListTest()
        {
            var list = new MyArrayList(2);

            Assert.IsNull(list.Find("Fred"));
            list.Add("Fred");

            Assert.AreEqual("Fred", list.Find("Fred"));
            Assert.IsNull(list.Find("Wilma"));
            Assert.AreEqual("Fred", list.Find("Fred"));
            list.Add("Wilma");
            Assert.AreEqual("Wilma", list.Find("Wilma"));
            var ans = new string[] { "Fred", "Wilma" };

            CollectionAssert.AreEqual(ans, list.Values());

            list = new MyArrayList(2);
            list.Add("Fred");
            list.Add("Wilma");
            list.Add("Betty");
            list.Add("Barney");
            ans = new string[] { "Fred", "Wilma", "Betty", "Barney" };
            CollectionAssert.AreEqual(ans, list.Values());
            list.Delete(list.Find("Wilma"));
            ans = new string[] { "Fred", "Betty", "Barney" };

            CollectionAssert.AreEqual(ans, list.Values());
            list.Delete(list.Find("Barney"));
            ans = new string[] { "Fred", "Betty" };
            CollectionAssert.AreEqual(ans, list.Values());
            list.Delete(list.Find("Fred"));
            ans = new string[] { "Betty" };
            CollectionAssert.AreEqual(ans, list.Values());
            list.Delete(list.Find("Betty"));
            ans = new string[] { };
            CollectionAssert.AreEqual(ans, list.Values());
        }