public void RemoveSpecificNodeDoesntExist() { LListDouble ll = new LListDouble(); Node first = new Node("First"); Node second = new Node("Second"); Node third = new Node("Third"); Node fourth = new Node("Fourth"); ll.Add(first); ll.Add(second); ll.Add(third); ll.Add(fourth); var removed = new Node("setup"); try { removed = ll.RemoveNode("Bob"); } catch { removed = null; } Assert.Null(removed); }
public void RemoveNodeFromFrontOfList() { LListDouble ll = new LListDouble(new Node("first")); Node second = new Node("second"); Node third = new Node("Third"); ll.Add(second); ll.Add(third); var removed = ll.RemoveHead(); Assert.Equal(third, removed); }
public void RemoveNodeFromEndOfList() { Node first = new Node("first"); LListDouble ll = new LListDouble(first); Node second = new Node("second"); Node third = new Node("Third"); ll.Add(second); ll.Add(third); var removed = ll.RemoveTail(); Assert.Equal(first, removed); }
public void RemoveSpecificNodeFromBackIfTail() { LListDouble ll = new LListDouble(); Node first = new Node("First"); Node second = new Node("Second"); Node third = new Node("Third"); ll.Add(first); ll.Add(second); ll.Add(third); var removed = ll.RemoveNode("First"); Assert.Equal(first, removed); }
public void AddNodeBeforeWhereSpecifiedNodeIsTrue(object value) { Node firstNode = new Node("First"); Node secondNode = new Node("Second"); Node thirdNode = new Node("Third"); LListDouble ll = new LListDouble(firstNode); ll.Add(secondNode); ll.Add(thirdNode); Node newNode = new Node(value); var IsSuccessful = ll.AddNodeBefore(newNode, firstNode); Assert.True(IsSuccessful); Assert.Equal(secondNode.Next, newNode); }
public void AddNodeAfterWhereSpecifiedNodeIsFalse(object value) { Node firstNode = new Node("First"); Node secondNode = new Node("Second"); Node thirdNode = new Node("Third"); Node randomNode = new Node("Nope"); LListDouble ll = new LListDouble(firstNode); ll.Add(secondNode); ll.Add(thirdNode); Node newNode = new Node(value); var IsSuccessful = ll.AddNodeAfter(newNode, randomNode); Assert.False(IsSuccessful); }
public void FindSpecificNodeIsFalse() { LListDouble ll = new LListDouble(); Node first = new Node("First"); Node second = new Node("Second"); Node third = new Node("Third"); Node fourth = new Node("Fourth"); ll.Add(first); ll.Add(second); ll.Add(third); ll.Add(fourth); var find = ll.Find("Bob"); Assert.False(find); }
public void AddNodeUpdateTheHead(object value) { LListDouble ll = new LListDouble(); Node newNode = new Node(value); Assert.Null(ll.Head); ll.Add(newNode); Assert.Equal(value, ll.Head.Value); }
public void RemoveSpecificNodeFromList() { LListDouble ll = new LListDouble(); Node first = new Node("First"); Node second = new Node("Second"); Node third = new Node("Third"); Node fourth = new Node("Fourth"); ll.Add(first); ll.Add(second); ll.Add(third); ll.Add(fourth); var removed = ll.RemoveNode("Third"); Assert.Equal(third, removed); Assert.Equal(second, ll.Head.Next); }
public void FindTheMiddleOfATheList() { Node first = new Node("First"); LListDouble ll = new LListDouble(); Node second = new Node("Second"); Node third = new Node("Third"); Node fourth = new Node("Fourth"); Node fifth = new Node("Fifth"); ll.Add(first); ll.Add(second); ll.Add(third); ll.Add(fourth); ll.Add(fifth); var middle = ll.MiddleOfList(); Assert.Equal(third, middle); }
public void AddNodeAfterWhereSpecifiedNodeIsHeadAndNextIsNotNull(object value) { Node firstNode = new Node("First"); Node secondNode = new Node("Second"); LListDouble ll = new LListDouble(firstNode); ll.Add(secondNode); Assert.Equal("Second", ll.Head.Value); Node newNode = new Node(value); ll.AddNodeAfter(newNode, secondNode); Assert.Equal(value, ll.Head.Next.Value); Assert.Equal(ll.Head.Value, secondNode.Value); }