public void AddHead_NodeBecomeHead()
        {
            MyOwnLinkedList <int> list = new MyOwnLinkedList <int>();

            list.Add_Head(13);
            Assert.AreEqual(13, list.head.Data);
        }
Пример #2
0
        static void Main(string[] args)
        {
            MyOwnLinkedList <int> list = new MyOwnLinkedList <int>();

            list.Add_Head(1);
            list.Add(2);
        }
        public void GetElementByIndex_ShouldThrow_IndexOutOfRangeException()
        {
            MyOwnLinkedList <int> list = new MyOwnLinkedList <int>();

            list.Add_Head(1);
            list.Add(2);
            Console.WriteLine(list[2]);
        }
        public void Remove_2_Should_Return_False()
        {
            MyOwnLinkedList <int> myLinkedList = new MyOwnLinkedList <int>(1);

            bool isRemoved = myLinkedList.Remove(2);

            Assert.IsFalse(isRemoved);
        }
        public void AddTail_NodeBecomeTail()
        {
            int last = 4;
            MyOwnLinkedList <int> list = new MyOwnLinkedList <int>();

            list.Add(2);
            list.Add_Tail(last);
            Assert.AreEqual(last, list.last.Data);
        }
        public void AddHead_Should_Increment_Count()
        {
            var myLinkedList = new MyOwnLinkedList <int>();

            var theCount = myLinkedList.Count;

            myLinkedList.Add_Head(2);
            myLinkedList.Add(2);

            Assert.AreEqual(theCount + 2, myLinkedList.Count);
        }
        public void RemoveHead_Next_Node_Should_Be_Head()
        {
            MyOwnLinkedList <int> list = new MyOwnLinkedList <int>();

            int[] array = new int[] { 1, 2, 5, 7, 10 };
            foreach (var i in array)
            {
                list.Add(i);
            }

            list.RemoveHead();

            Assert.AreEqual(2, list.head.Data);
        }