public void BrutalForceMethodTest() { var result = new NthElementFromEnd().BrutalForceMethod(EmptyList, 4); Assert.IsNull(result); result = new NthElementFromEnd().BrutalForceMethod(SingleNodeList, 1); Assert.AreEqual(1, ((LinkedListNode)result).Value); result = new NthElementFromEnd().BrutalForceMethod(SingleNodeList, 2); Assert.IsNull(result); result = new NthElementFromEnd().BrutalForceMethod(List,4); Assert.AreEqual(3,((LinkedListNode)result).Value); result = new NthElementFromEnd().BrutalForceMethod(List, 7); Assert.IsNull(result); result = new NthElementFromEnd().BrutalForceMethod(List, 6); Assert.AreEqual(1, ((LinkedListNode)result).Value); result = new NthElementFromEnd().BrutalForceMethod(List, 1); Assert.AreEqual(6, ((LinkedListNode)result).Value); }
public void UsingHashTable() { //Empty List var result = new NthElementFromEnd().UsingHashTable(EmptyList, 4); Assert.IsNull(result); //Single node list result = new NthElementFromEnd().UsingHashTable(SingleNodeList, 1); Assert.AreEqual(1, ((LinkedListNode)result).Value); result = new NthElementFromEnd().UsingHashTable(SingleNodeList, 2); Assert.IsNull(result); //Multi node list result = new NthElementFromEnd().UsingHashTable(List, 4); Assert.AreEqual(3, ((LinkedListNode)result).Value); result = new NthElementFromEnd().UsingHashTable(List, 7); Assert.IsNull(result); result = new NthElementFromEnd().UsingHashTable(List, 6); Assert.AreEqual(1, ((LinkedListNode)result).Value); result = new NthElementFromEnd().UsingHashTable(List, 1); Assert.AreEqual(6, ((LinkedListNode)result).Value); }