public void Search_Success() { var head = new MockLinkedNode <int>(20) { Next = new MockLinkedNode <int>(10) }; head.Next.Next = new MockLinkedNode <int>(12) { }; head.Next.Next.Next = new MockLinkedNode <int>(6); var list = new MockLinkedList <int>(head); var result = list.Search(20); Assert.IsNotNull(result); Assert.AreEqual(20, result.Value); result = list.Search(12); Assert.IsNotNull(result); Assert.AreEqual(12, result.Value); }
public void Length() { var list = new MockLinkedList <int>(); Assert.AreEqual(0, list.Count()); var head = new MockLinkedNode <int>(10); list = new MockLinkedList <int>(head); Assert.AreEqual(1, list.Count()); head.Next = new MockLinkedNode <int>(2); list = new MockLinkedList <int>(head); Assert.AreEqual(2, list.Count()); head.Next.Next = new MockLinkedNode <int>(20); list = new MockLinkedList <int>(head); Assert.AreEqual(3, list.Count()); head.Next.Next.Next = new MockLinkedNode <int>(3); list = new MockLinkedList <int>(head); Assert.AreEqual(4, list.Count()); }
public void Search_NonEmptyListAndNotExistingValue_ThrowsException() { var list = new MockLinkedList <int>(new MockLinkedNode <int>(20)); var result = list.Search(10); }