public void InsertAfterHeadOfEmptyList_ShouldThrowInvalidOperationException() { var list = new DblLinkedList <string>(); list.Invoking(l => l.InsertAfter(l.Head, DblLinkedList.CreateNode("1"))) .ShouldThrow <InvalidOperationException>(); }
public void InsertBeforeTailOfEmptyList_ShouldThrowInvalidOperationException() { var list = new DblLinkedList <string>(); list.Invoking(l => l.InsertBefore(l.Tail, DblLinkedList.CreateNode("1"))) .ShouldThrow <InvalidOperationException>(); }
public void InsertAfterNull_ShouldThrowArgumentException() { var list = new DblLinkedList <string>(); list.Invoking(l => l.InsertAfter(null, DblLinkedList.CreateNode("1"))) .ShouldThrow <ArgumentNullException>(); }
public void InsertedToTailOfEmptyListNode_ShouldBeHeadOfList() { var list = new DblLinkedList <int>(); var node = DblLinkedList.CreateNode(1); list.InsertTail(node); list.Head.Should().Be(node); }
public void ListWithOneItem_ShouldNotBeEmpty() { var list = new DblLinkedList <int>(); var node = DblLinkedList.CreateNode(1); list.InsertHead(node); list.IsEmpty().Should().BeFalse(); }
public void ListAfterInsertingAndRemovingNode_ShouldBeEmpty() { var list = new DblLinkedList <int>(); var node = DblLinkedList.CreateNode(1); list.InsertTail(node); list.Remove(node); list.IsEmpty().Should().BeTrue(); }
public void InsertedToTailTwoNodes_ShouldBeInListInRightOrder() { var list = new DblLinkedList <int>(); list.InsertTail(DblLinkedList.CreateNode(1)); list.InsertTail(DblLinkedList.CreateNode(2)); list.Tail.Value.Should().Be(2); list.Tail.Prev.Value.Should().Be(1); }
public void InsertedToHeadTwoNodes_ShouldBeInListInRightOrder() { var list = new DblLinkedList <int>(); list.InsertHead(DblLinkedList.CreateNode(1)); list.InsertHead(DblLinkedList.CreateNode(2)); list.Head.Value.Should().Be(2); list.Head.Next.Value.Should().Be(1); }
public void IterativeInsertAfterTail_ShouldProduceCorrectList(IList <int> input) { var list = new DblLinkedList <int>(); foreach (var i in input) { list.InsertAfter(list.Tail, DblLinkedList.CreateNode(i)); } VerifyList(list, input); }
public void IterativeInsertBeforeHead_ShouldProduceCorrectList(IList <int> input) { var list = new DblLinkedList <int>(); foreach (var i in input.Reverse()) { list.InsertBefore(list.Head, DblLinkedList.CreateNode(i)); } VerifyList(list, input); }
public void InsertedAfterTailNode_ShouldBecomeTheTailOfList() { var list = new DblLinkedList <int>(); list.InsertTail(DblLinkedList.CreateNode(1)); var newNode = DblLinkedList.CreateNode(3); list.InsertAfter(list.Tail, newNode); list.Tail.Value.Should().Be(newNode.Value); }
public void InsertedBeforeHeadNode_ShouldBecomeTheHeadOfList() { var list = new DblLinkedList <int>(); list.InsertHead(DblLinkedList.CreateNode(1)); var newNode = DblLinkedList.CreateNode(3); list.InsertBefore(list.Head, newNode); list.Head.Value.Should().Be(newNode.Value); }
public void InsertedAfterNode_ShouldBeInsertedInsertedInRightPlace() { var list = new DblLinkedList <int>(); var node1 = DblLinkedList.CreateNode(1); list.InsertHead(node1); var newNode = DblLinkedList.CreateNode(2); list.InsertAfter(node1, newNode); list.Head.Next.Value.Should().Be(newNode.Value); }
public void AfterRemovingHeadNode_HeadShouldBeChanged() { var list = new DblLinkedList <int>(); var node1 = DblLinkedList.CreateNode(1); var node2 = DblLinkedList.CreateNode(2); list.InsertHead(node1); list.InsertHead(node2); list.Remove(node2); list.Head.Value.Should().Be(node1.Value); }
public void IterativeInsertBefore_ShouldProduceCorrectList() { var input = new string[] { "1", "2", "3" }; var list = new DblLinkedList <string>(); var currentNode = list.Head; foreach (var i in input.Reverse()) { currentNode = list.InsertBefore(currentNode, DblLinkedList.CreateNode(i)); } VerifyList(list, input); }