public void DeleteInEmptyList_IndexOutOfRangeExeption() { DoublyLinkedList <string> testList = new DoublyLinkedList <string>(); Assert.ThrowsException <IndexOutOfRangeException>( () => testList.DeleteAtIndex(1)); }
public void DeleteAtIndex_IndexOutOfRangeException(int index) { DoublyLinkedList <string> testList = new DoublyLinkedList <string>("1", "2", "3", "4", "5"); Xunit.Assert.Throws <IndexOutOfRangeException>( () => testList.DeleteAtIndex(index)); }
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); }
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); }
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); }
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); }