예제 #1
0
        public void TestInsertTwo()
        {
            MyLinkedList l1 = new MyLinkedList();

            l1.Insert(c2);
            l1.Insert(c1);
            Assert.AreEqual(2, l1.Count);
            Assert.AreEqual("2 Bjørn Borg 30\n1 Anders And 15\n", l1.ToString());
        }
예제 #2
0
        public void TestInsertOne()
        {
            MyLinkedList l1 = new MyLinkedList();

            Assert.AreEqual(0, l1.Count);
            l1.Insert(c1);
            Assert.AreEqual(1, l1.Count);
            Assert.AreEqual("1 Anders And 15\n", l1.ToString());
        }
예제 #3
0
        public void TestItemAt()
        {
            MyLinkedList l1 = new MyLinkedList();

            l1.Insert(c2);
            l1.Insert(c1);
            Assert.AreEqual(c2, l1.ItemAt(0));
            Assert.AreEqual(c1, l1.ItemAt(1));
            Assert.AreEqual("2 Bjørn Borg 30\n1 Anders And 15\n", l1.ToString());
        }
        public void TestGenericMixedInsertsAndRemoves()
        {
            MyLinkedList <ClubMember> list = new MyLinkedList <ClubMember>();

            list.Insert(p3);             // p3
            list.Append(p22);            // p3,p22
            list.Insert(p9);             // p9,p3,p22
            list.Delete(0);              // p3,p22
            list.Insert(p1);             // p1,p3,p22
            list.Append(p24);            // p1,p3,p22,p24
            list.Insert(p5);             // p5,p1,p3,p22,p24
            list.Delete(4);              // p5,p1,p3,p22
            list.Append(p16);            // p5,p1,p3,p22,p16
            list.Delete(2);              // p5,p1,p22,p16

            Assert.AreEqual(p5, list.First);
            Assert.AreEqual(p16, list.Last);
            Assert.AreEqual(4, list.Count);

            Assert.AreEqual(p5, list.ItemAt(0));
            Assert.AreEqual(p1, list.ItemAt(1));
            Assert.AreEqual(p22, list.ItemAt(2));
            Assert.AreEqual(p16, list.ItemAt(3));
            Assert.AreEqual("5: Jarib Boustred (Male, 32 years)\n1: Farrand Semkins (Female, 77 years)\n22: Merle Bennet (Female, 42 years)\n16: Tore Saggs (Male, 28 years)\n", list.ToString());
        }
예제 #5
0
        public void TestDeleteAt()
        {
            MyLinkedList l1 = new MyLinkedList();

            l1.Insert(c2);
            l1.Insert(c1);
            l1.Insert(c3, 1);
            l1.Insert(c4, 0);
            l1.Insert(c5, 4);
            l1.Delete(3);
            l1.Delete(3);
            Assert.AreEqual(3, l1.Count);
            Assert.AreEqual("4 Kurt Nielsen 33\n2 Bjørn Borg 30\n3 Cristian Nielsen 20\n", l1.ToString());
        }
예제 #6
0
        public void TestInsertAt()
        {
            MyLinkedList l1 = new MyLinkedList();

            l1.Insert(c2);
            l1.Insert(c1);
            l1.Insert(c3, 1);
            l1.Insert(c4, 0);
            l1.Insert(c5, 4);
            Assert.AreEqual(5, l1.Count);
            Assert.AreEqual("4 Kurt Nielsen 33\n2 Bjørn Borg 30\n3 Cristian Nielsen 20\n1 Anders And 15\n5 Lis Sørnsen 18\n", l1.ToString());
        }
예제 #7
0
        public void Testswap()
        {
            MyLinkedList l1 = new MyLinkedList();

            l1.Insert(c3);
            l1.Insert(c1);
            l1.Insert(c2);
            l1.Swap(1);
            Assert.AreEqual(3, l1.Count);
            Assert.AreEqual("3 Cristian Nielsen 20\n2 Bjørn Borg 30\n1 Anders And 15\n", l1.ToString());
        }