public void AddAfter() { SinglyLinkedList list = new SinglyLinkedList(); list.AddLast("foo"); list.AddLast("grille"); // NOTE: This assert isn't necessary. It is merely here to remind you of / verify the state of the list prior to inserting the new node. var expected = new string[] { "foo", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); list.AddAfter("foo", "bar"); expected = new string[] { "foo", "bar", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void SortingWithInt() { SinglyLinkedList<int> list = new SinglyLinkedList<int>(new int[] { 4, 1, 3, 2 }); list.Sort(); int[] expected = { 1, 2, 3, 4 }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ConstructorWithOneArgument() { SinglyLinkedList list = new SinglyLinkedList("foo"); var expected = new string[] { "foo" }; //throw new ArgumentException(list.ToArray().ToString()); CollectionAssert.AreEqual(expected, list.ToArray()); }
public void AddFirstOnEmptyList() { SinglyLinkedList list = new SinglyLinkedList(); list.AddFirst("foo"); string[] expected = new string[] { "foo" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void AddAfterLastItem() { SinglyLinkedList list = new SinglyLinkedList(); list.AddLast("foo"); list.AddLast("bar"); list.AddAfter("bar", "grille"); var expected = new string[] { "foo", "bar", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void AddFirstOnLongerList() { SinglyLinkedList list = new SinglyLinkedList(); list.AddLast("foo"); list.AddLast("bar"); list.AddFirst("grille"); var expected = new string[] { "grille", "foo", "bar" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void CaitlinsArrayCount() { SinglyLinkedList list = new SinglyLinkedList(); list.AddLast("foo"); list.AddLast("bar"); list.AddLast("grille"); string[] lexpected = new string[] { "foo", "bar", "grille" }; int expected = lexpected.Length; string[] lactual = list.ToArray(); int actual = lactual.Length; Assert.AreEqual(expected, actual); }
public void ListRemoveWithDuplicateNodes() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille", "bar"); list.Remove("bar"); var expected = new string[] { "foo", "grille", "bar" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ListRemoveNonExistentNode() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille"); list.Remove("cat"); var expected = new string[] { "foo", "bar", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ListRemoveLastItemFromList() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille"); list.Remove("grille"); var expected = new string[] { "foo", "bar" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ListBracketAssignmentPreservesRestOfList() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille"); list[2] = "cat"; var expected = new string[] { "foo", "bar", "cat" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void SortEmptyList() { SinglyLinkedList list = new SinglyLinkedList(); list.Sort(); var expected = new string[] { }; //hrow new ArgumentException(list.ToString()); CollectionAssert.AreEqual(expected, list.ToArray()); }
public void SwapWithNextItemN() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille", "zoo", "cat"); PrivateObject listObj = new PrivateObject(list); SinglyLinkedListNode nodeTwo = (SinglyLinkedListNode)listObj.Invoke("NodeAt", 2); SinglyLinkedListNode nodeThree = (SinglyLinkedListNode)listObj.Invoke("NodeAt", 3); listObj.Invoke("SwapWithNext", nodeTwo, nodeThree); var expected = new string[] { "foo", "bar", "grille", "cat", "zoo" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ToArrayOnSingleItemList() { SinglyLinkedList list = new SinglyLinkedList(); list.AddLast("foo"); string[] expected = new string[] { "foo" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void SortSortedList() { SinglyLinkedList<string> list = new SinglyLinkedList<string>("bar", "cat", "foo", "grille"); list.Sort(); var expected = new string[] { "bar", "cat", "foo", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void SortUnsortedList() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar"); list.Sort(); var expected = new string[] { "bar", "foo" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void SortSingleItemList() { SinglyLinkedList<string> list = new SinglyLinkedList<string>("foo"); list.Sort(); var expected = new string[] { "foo" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ListRemoveItemFromMiddleOfList() { SinglyLinkedList<string> list = new SinglyLinkedList<string>("foo", "bar", "grille"); list.Remove("bar"); var expected = new string[] { "foo", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ListRemoveFirstNode() { SinglyLinkedList<string> list = new SinglyLinkedList<string>("foo", "bar", "grille"); list.Remove("foo"); var expected = new string[] { "bar", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void SortEmptyList() { SinglyLinkedList list = new SinglyLinkedList(); list.Sort(); var expected = new string[] { }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ListRemoveFirstNode() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille"); list.Remove("foo"); var expected = new string[] { "bar", "grille" }; //throw new ArgumentException(list.ToString()); CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ToArrayOnMultipleItemList() { SinglyLinkedList<string> list = new SinglyLinkedList<string>(); list.AddLast("foo"); list.AddLast("bar"); list.AddLast("grille"); string[] expected = new string[] { "foo", "bar", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void SortLongerList() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille", "zoo", "cat"); list.Sort(); var expected = new string[] { "bar", "cat", "foo", "grille", "zoo" }; //throw new ArgumentException(list.ToString()); CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ToArrayOnEmptyList() { SinglyLinkedList list = new SinglyLinkedList(); string[] expected = new string[] { }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ConstructorWithOneArgument() { SinglyLinkedList list = new SinglyLinkedList("foo" , "boo"); var expected = new string[] { "foo" , "boo" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void SortUnsortedList() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar"); list.Sort(); var expected = new string[] { "bar", "foo" }; // This passes, but removing the ToString() fails. WHY??? Assert.AreEqual(expected.ToString(), list.ToArray().ToString()); // Assert.AreEqual(2, list.Count()) works // Assert.AreEqual("bar", list.ToArray()[0]) works // Assert.AreEqual("foo", list.ToArray()[1]) works }
public void SwapWithNextItem0() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille", "zoo", "cat"); PrivateObject listObj = new PrivateObject(list); SinglyLinkedListNode nodeZero = (SinglyLinkedListNode) listObj.Invoke("NodeAt", new object[] { 0 }); listObj.Invoke("SwapWithNext", null, nodeZero); var expected = new string[] { "bar", "foo", "grille", "zoo", "cat" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ConstructorWithMultipleArguments() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille"); var expected = new string[] { "foo", "bar", "grille" }; CollectionAssert.AreEqual(expected, list.ToArray()); }
public void ListBracketAssignmentPreservesRestOfList() { SinglyLinkedList list = new SinglyLinkedList("foo", "bar", "grille"); list[2] = "cat"; var expected = new string[] { "foo", "bar", "cat" }; //throw new ArgumentException(list.ToString()); // foo cat cat grille CollectionAssert.AreEqual(expected, list.ToArray()); }