/// <summary> /// Test adding an item to an empty linked list /// </summary> static void TestAddEmptyLinkedList() { LinkedList <string> list = new UnsortedLinkedList <string>(); list.Add("Foxtrot"); Console.Write("TestAddEmptyLinkedList: "); string liststring = list.ToString(); if (liststring.Equals("Foxtrot") && list.Count == 1) { Console.WriteLine("Passed"); } else { Console.WriteLine("FAILED!!! Expected: Foxtrot and 1 Actual: " + liststring + " and " + list.Count); } }
/// <summary> /// Test removing an item from the interior of the list /// </summary> static void TestRemoveItemFromInteriorOfLinkedList() { UnsortedLinkedList <string> list = new UnsortedLinkedList <string>(); list.Add("Foxtrot"); list.Add("Echo"); list.Add("Delta"); Console.Write("TestRemoveItemInteriorOfLinkedList: "); bool removed = list.Remove("Echo"); string listString = list.ToString(); if (removed && listString.Equals("Delta,Foxtrot") && list.Count == 2) { Console.WriteLine("Passed"); } else { Console.WriteLine("FAILED!!! Expected: Delta,Foxtrot and 2 Actual: " + listString + " and " + list.Count); } }