Ejemplo n.º 1
0
        public void AddToList_1Point()
        {
            IIntegerList list = new IntegerList();

            list.Add(10);

            Assert.AreEqual(10, list.GetElement(0));
            Assert.AreEqual(1, list.Count);

            list.Add(11);
            Assert.AreEqual(10, list.GetElement(0));
            Assert.AreEqual(11, list.GetElement(1));

            Assert.AreEqual(2, list.Count);
        }
Ejemplo n.º 2
0
        public void RemoveFromList_1Point()
        {
            IIntegerList list = new IntegerList();

            list.Add(11);
            list.Add(2);
            list.Add(11);

            Assert.AreEqual(false, list.Remove(10));
            Assert.AreEqual(3, list.Count);

            // will remove only first occurence
            Assert.AreEqual(true, list.Remove(11));
            Assert.AreEqual(11, list.GetElement(1));
            Assert.AreEqual(2, list.GetElement(0));
        }
Ejemplo n.º 3
0
        public void RemoveAtIndex_1Point()
        {
            IIntegerList list = new IntegerList();

            list.Add(11);

            Assert.AreEqual(true, list.RemoveAt(0));
            Assert.AreEqual(0, list.Count);

            list.Add(11);
            list.Add(12);
            list.Add(13);

            Assert.AreEqual(true, list.RemoveAt(1));
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual(11, list.GetElement(0));
            Assert.AreEqual(13, list.GetElement(1));
        }
Ejemplo n.º 4
0
        public void ListRebuildTest_1Point()
        {
            IIntegerList list = new IntegerList(100);

            for (int i = 0; i < 100000; i++)
            {
                list.Add(i);
            }

            Assert.AreEqual(100000, list.Count);

            for (int i = 0; i < 100000; i++)
            {
                Assert.AreEqual(i, list.GetElement(i));
            }
        }
Ejemplo n.º 5
0
        public void GetElement_ThrowsIndexOutOfRangeException_1Point()
        {
            IIntegerList list = new IntegerList();

            list.GetElement(100);
        }