Exemplo n.º 1
0
        public void DeleteInEmptyList_IndexOutOfRangeExeption()
        {
            DoublyLinkedList <string> testList = new DoublyLinkedList <string>();

            Assert.ThrowsException <IndexOutOfRangeException>(
                () => testList.DeleteAtIndex(1));
        }
Exemplo n.º 2
0
        public void DeleteAtIndex_IndexOutOfRangeException(int index)
        {
            DoublyLinkedList <string> testList = new DoublyLinkedList <string>("1", "2", "3", "4", "5");

            Xunit.Assert.Throws <IndexOutOfRangeException>(
                () => testList.DeleteAtIndex(index));
        }
Exemplo n.º 3
0
        public void DeleteOneMiddleAndOneLastElements_ElementsAreDeletedCorrectly_FromTail()
        {
            List <string> expected = new List <string> {
                "4", "2", "1"
            };
            DoublyLinkedList <string> testList = new DoublyLinkedList <string>();

            testList.AddToTail("1");
            testList.AddToTail("2");
            testList.AddToTail("3");
            testList.AddToTail("4");
            testList.AddToTail("5");

            testList.DeleteAtIndex(3);
            testList.DeleteAtIndex(4);

            List <string> actual = CheckPreviousLinks(testList);

            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 4
0
        public void DeleteTheOnlyExistedElement_TheListIsEmpty_FromTail()
        {
            List <string> expected             = new List <string> {
            };
            DoublyLinkedList <string> testList = new DoublyLinkedList <string>();

            testList.AddToTail("1");

            testList.DeleteAtIndex(1);

            List <string> actual = CheckPreviousLinks(testList);

            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 5
0
        public void DeleteAtIndex_TheRightElementIsDeleted(int value)
        {
            List <string> expected = new List <string> {
                "1", "2", "3", "4", "5"
            };
            DoublyLinkedList <string> testList = new DoublyLinkedList <string>("1", "2", "3", "4", "5");

            testList.DeleteAtIndex(value);
            expected.RemoveAt(value - 1);

            List <string> actualNextLinks     = CheckNextLinks(testList);
            List <string> actualPreviousLinks = CheckPreviousLinks(testList);

            CollectionAssert.AreEqual(actualNextLinks, expected);
            expected.Reverse();
            CollectionAssert.AreEqual(actualPreviousLinks, expected);
        }
Exemplo n.º 6
0
        public void DeleteOneMiddleElement_ElementIsDeletedCorrectly_FromHead()
        {
            List <string> expected = new List <string> {
                "1", "2", "4", "5"
            };
            DoublyLinkedList <string> testList = new DoublyLinkedList <string>();

            testList.AddToTail("1");
            testList.AddToTail("2");
            testList.AddToTail("3");
            testList.AddToTail("4");
            testList.AddToTail("5");

            testList.DeleteAtIndex(3);

            List <string> actual = CheckNextLinks(testList);

            CollectionAssert.AreEqual(expected, actual);
        }