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));
        }
        public void GetElementInRange()
        {
            MyList <int> List = new MyArrayList <int>();

            List.Add(52);
            List.Add(95);
            Assert.AreEqual(List.Get(0), 52);
            Assert.AreEqual(List.Get(1), 95);
        }
예제 #3
0
        public void GetTest(int[] val, int index, int expected)
        {
            MyArrayList myAL = new MyArrayList(val);

            int actual = myAL.Get(index);

            Assert.AreEqual(expected, actual);
        }
        public void GetElementOutOfRange()
        {
            MyList <int> List = new MyArrayList <int>();

            List.Add(52);
            List.Add(95);
            try
            {
                List.Get(2);
            }
            catch (IndexOutOfRangeException e)
            {
                StringAssert.Contains(e.Message, "Индекс вне диапазона.");
            }
        }
 public void GetElementOutOfRange()
 {
     MyList<int> List = new MyArrayList<int>();
     List.Add(52);
     List.Add(95);
     try
     {
         List.Get(2);
     }
     catch (IndexOutOfRangeException e)
     {
         StringAssert.Contains(e.Message, "Индекс вне диапазона.");
     }
 }
 public void GetElementInRange()
 {
     MyList<int> List = new MyArrayList<int>();
     List.Add(52);
     List.Add(95);
     Assert.AreEqual(List.Get(0), 52);
     Assert.AreEqual(List.Get(1), 95);
 }