示例#1
0
        public void AddToTheEnd_NotEmptyList_Success()
        {
            SinglyLinkedList <int> list = new SinglyLinkedList <int>();

            list.AddToTheEnd(10);
            list.AddToTheEnd(20);

            Assert.IsNotNull(list.Head.Next);
            Assert.AreEqual(20, list.Head.Next.Data);
        }
示例#2
0
        public void Find_ElementDoesNotExist_Success()
        {
            SinglyLinkedList <int> list = new SinglyLinkedList <int>();

            list.AddToTheEnd(10);
            list.AddToTheEnd(20);
            list.AddToTheEnd(30);
            ListNode <int> result = list.FindElement(50);

            Assert.IsNull(result);
        }
示例#3
0
        public void Find_ElementIsLast_Success()
        {
            SinglyLinkedList <int> list = new SinglyLinkedList <int>();

            list.AddToTheEnd(10);
            list.AddToTheEnd(20);
            list.AddToTheEnd(30);
            ListNode <int> result = list.FindElement(20);

            Assert.IsNotNull(result);
            Assert.AreEqual(20, result.Data);
        }
示例#4
0
        public void Delete_LastElement_Success()
        {
            SinglyLinkedList <int> list = new SinglyLinkedList <int>();

            list.AddToTheEnd(10);
            list.AddToTheEnd(20);
            bool result = list.DeleteNode(20);

            Assert.IsTrue(result);
            Assert.IsNotNull(list.Head);
            Assert.IsNull(list.Head.Next);
        }