public void tDeleteMiddleNode() { ListNode nodeE = new ListNode('E'); ListNode nodeD = new ListNode('D', nodeE); ListNode nodeC = new ListNode('C', nodeD); ListNode nodeB = new ListNode('B', nodeC); ListNode nodeA = new ListNode('A', nodeB); ListNode node = nodeA; char result; bool exists = false; DeleteMiddleNode.DeleteNode(nodeC); while (!ReferenceEquals(null, node)) { result = node.data; if (result == 'C') { exists = true; break; } node = node.next; } Assert.IsFalse(exists); }
public void Test1() { MyLinkedList list = new MyLinkedList(); list.AddLast(new MyNode(1)); list.AddLast(new MyNode(2)); list.AddLast(new MyNode(3)); list.AddLast(new MyNode(4)); list.AddLast(new MyNode(5)); int initCount = list.Count; deleteMiddleNode.DeleteNode(list, 3); int newCount = list.Count; Assert.AreEqual(initCount, newCount + 1); }