Esempio n. 1
0
        public void AddBeforeAndAfterTest()
        {
            CircularLinkedListNode <int> node = threeList.Find(3);

            threeList.AddAfter(node, new CircularLinkedListNode <int>(5));
            CircularLinkedListNode <int> sixNode   = threeList.AddAfter(node, 6);
            CircularLinkedListNode <int> sevenNode = threeList.AddBefore(node, 7);

            threeList.AddBefore(node, new CircularLinkedListNode <int>(8));

            Assert.AreEqual(6, sixNode.Value);
            Assert.AreEqual(7, sevenNode.Value);

            // 2 7 8 3 6 5 4
            int[] values = new int[] { 2, 7, 8, 3, 6, 5, 4 };
            int   i      = 0;

            foreach (int current in threeList)
            {
                Assert.AreEqual(values[i], current);
                i++;
            }

            CircularLinkedListNode <int> node2 = threeList.First;

            do
            {
                Assert.AreSame(threeList, node2.List);
                node2 = node2.Next;
            }while (node2 != threeList.First);
        }