static void Opgave1()
        {
            System.Console.WriteLine("\n=====   Opgave 1 : MyArrayList   =====\n");

            MyArrayList al = new MyArrayList(10);

            System.Console.WriteLine(al);
            al.Add(2);
            al.Add(3);
            al.Add(5);
            System.Console.WriteLine(al);
            Console.WriteLine(al.Get(0));
            try
            {
                Console.WriteLine(al.Get(3));
            }
            catch (MyArrayListIndexOutOfRangeException e)
            {
                Console.WriteLine(e.Message);
            }
            al.Set(2, 4);
            System.Console.WriteLine(al);

            al.Clear();
            for (int i = 0; i < 10; i++)
            {
                al.Add(i);
            }
            al.Set(9, 2);
            al.Set(7, 2);
            System.Console.WriteLine(al);
            Console.WriteLine(al.CountOccurences(2));
        }
Пример #2
0
        public void ClearTest()
        {
            list.Add(7);
            list.Add(9);

            list.Clear();
            Assert.AreEqual(0, list.Count);
        }
 public void ClearTest()
 {
     MyList<int> List = new MyArrayList<int>();
     List.Add(1);
     List.Add(2);
     List.Clear();
     Assert.AreEqual(List.Count, 0);
     Assert.AreEqual((List as MyArrayList<int>).Capacity, 10);
 }
        public void ClearTest()
        {
            MyList <int> List = new MyArrayList <int>();

            List.Add(1);
            List.Add(2);
            List.Clear();
            Assert.AreEqual(List.Count, 0);
            Assert.AreEqual((List as MyArrayList <int>).Capacity, 10);
        }
Пример #5
0
        public void Should_clear_elements()
        {
            var arrayList = new MyArrayList();

            arrayList.Add(5);
            arrayList.Add(2);
            arrayList.Add(1);

            arrayList.Clear();

            Assert.Empty(arrayList);
        }
Пример #6
0
        static void TestMyArrayList()
        {
            MyArrayList <string> temp = new MyArrayList <string>();

            temp.Add("fuck1");
            temp.Add("fuck2");
            temp.Add("fuck3");
            temp.Add("fuck4");
            temp.Add("fuckall");

            temp.RemoveAt(3);

            for (int i = 0; i < temp.Count; i++)
            {
                Console.WriteLine(temp[i]);
            }

            Console.WriteLine("Contains fuck4: " + temp.Contains("fuck4") + temp.Find("fuck4"));
            Console.WriteLine("Contains fuck3: " + temp.Contains("fuck3") + temp.Find("fuck3"));

            temp.Insert(3, "fuck4");

            Console.WriteLine("Contains fuck4: " + temp.Contains("fuck4") + temp.Find("fuck4"));
            Console.WriteLine("Contains fuck3: " + temp.Contains("fuck3") + temp.Find("fuck3"));

            for (int i = 0; i < temp.Count; i++)
            {
                Console.WriteLine(temp[i]);
            }

            temp.Reverse();

            for (int i = 0; i < temp.Count; i++)
            {
                Console.WriteLine(temp[i]);
            }

            temp.Insert(3, "fuckbbb");
            temp.Sort();

            for (int i = 0; i < temp.Count; i++)
            {
                Console.WriteLine(temp[i]);
            }

            temp.Clear();

            for (int i = 0; i < temp.Count; i++)
            {
                Console.WriteLine(temp[i]);
            }
        }
Пример #7
0
        public void Should_Clear()
        {
            //arrange
            var list = new MyArrayList();

            list.Add(1);
            list.Add(3);
            list.Add(4);
            list.Add(4);
            list.Add(4);

            object item;

            //act
            list.Clear();
            Action act = () => item = list[0];

            //assert
            list.Capacity.ShouldBeEquivalentTo(8);
            list.Count.ShouldBeEquivalentTo(0);
            act.ShouldThrow <ArgumentOutOfRangeException>();
        }
Пример #8
0
 public void TestClear()
 {
     list.Clear();
     Assert.AreEqual(0, list.Count);
     Assert.AreEqual("[]", list.Show);
 }
 public void Clear()
 {
     _collection.Clear();
 }