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 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 InsertedBeforeNode_ShouldBeInsertedInsertedInRightPlace() { var list = new DblLinkedList <int>(); var node1 = DblLinkedList.CreateNode(1); var node2 = DblLinkedList.CreateNode(2); list.InsertHead(node1); list.InsertHead(node2); var newNode = DblLinkedList.CreateNode(3); list.InsertBefore(node1, newNode); list.Head.Next.Value.Should().Be(newNode.Value); }
public void InsertedToHeadOfEmptyListNode_ShouldBeTailOfList() { var list = new DblLinkedList <int>(); var node = DblLinkedList.CreateNode(1); list.InsertHead(node); list.Tail.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 IterativeInsertHead_ShouldProduceCorrectList(IList <int> input) { var list = new DblLinkedList <int>(); foreach (var i in input.Reverse()) { list.InsertHead(DblLinkedList.CreateNode(i)); } VerifyList(list, input); }
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); }