示例#1
0
        public void AddAtWrongIndex_IndexOutOfRangeException()
        {
            DoublyLinkedList <string> testList = new DoublyLinkedList <string>();

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

            Assert.ThrowsException <IndexOutOfRangeException>(
                () => testList.Insert(7, "3"));
        }
示例#2
0
        public void Insert_TheRightElementIsAdded(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.Insert(value, "0");
            expected.Insert(value - 1, "0");

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

            CollectionAssert.AreEqual(actualNextLinks, expected);
            expected.Reverse();
            CollectionAssert.AreEqual(actualPreviousLinks, expected);
        }
示例#3
0
        public void AddOneElementToTheMiddle_ElementsAreInRightOrder_FromTail()
        {
            List <string> expected = new List <string> {
                "5", "4", "3", "2", "1"
            };
            DoublyLinkedList <string> testList = new DoublyLinkedList <string>();

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

            testList.Insert(3, "3");

            List <string> actual = CheckPreviousLinks(testList);

            CollectionAssert.AreEqual(expected, actual);
        }