public void Add_After_Count_0_Does_Not_Add() { var linkedList = new DoubleLinkedList <int>(); var newNode = new DoubleLinkedListNode <int>(1); var nodeNotInList = new DoubleLinkedListNode <int>(2); linkedList.AddAfter(nodeNotInList, newNode); linkedList.Count.Should().Be(0); }
public void Can_Add_After_Element() { var linkedList = new DoubleLinkedList <int>(); var node1 = new DoubleLinkedListNode <int>(1); var node2 = new DoubleLinkedListNode <int>(2); var newNode = new DoubleLinkedListNode <int>(3); linkedList.AddFirst(node1); linkedList.AddLast(node2); linkedList.AddAfter(node1, newNode); linkedList.Count.Should().Be(3); linkedList.First.Should().Be(node1); linkedList.Last.Should().Be(node2); linkedList.First.Value.Should().Be(1); linkedList.First.Next.Value.Should().Be(3); linkedList.Last.Value.Should().Be(2); linkedList.Last.Previous.Value.Should().Be(3); }