示例#1
0
        public void TestInsertBeforeFirst()
        {
            VisitableLinkedList <int> list           = GetTestCustomLinkedList();
            LinkedListNode <int>      currentElement = list.First;

            list.AddBefore(currentElement, 657);
            Assert.AreEqual(list.First.Value, 657);

            currentElement = list.First;

            // Verify the list items and their contents
            for (int i = 0; i < 6; i++)
            {
                if (i == 0)
                {
                    Assert.AreEqual(currentElement.Value, 657);
                }
                else
                {
                    Assert.AreEqual(currentElement.Value, (i - 1) * 3);
                }

                currentElement = currentElement.Next;
            }
        }
示例#2
0
        public void TestInsertBefore1Item()
        {
            VisitableLinkedList <int> list = new VisitableLinkedList <int>();

            list.AddLast(5);

            list.AddBefore(list.First, 6);

            Assert.AreEqual(list.First.Value, 6);
            Assert.AreEqual(list.First.Next.Value, 5);
            Assert.AreEqual(list.Last.Value, 5);
        }