Ejemplo n.º 1
0
        public void TestMixedInsertsAndRemoves()
        {
            LinkedLists list = new LinkedLists();

            list.InsertFirst(p3); // p3
            list.InsertLast(p22); // p3,p22
            list.InsertFirst(p9); // p9,p3,p22
            list.RemoveAt(0);     // p3,p22
            list.InsertFirst(p1); // p1,p3,p22
            list.InsertLast(p24); // p1,p3,p22,p24
            list.InsertFirst(p5); // p5,p1,p3,p22,p24
            list.RemoveAt(4);     // p5,p1,p3,p22
            list.InsertLast(p16); // p5,p1,p3,p22,p16
            list.RemoveAt(2);     // p5,p1,p22,p16

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

            Assert.AreEqual(p5, list.Items(0));
            Assert.AreEqual(p1, list.Items(1));
            Assert.AreEqual(p22, list.Items(2));
            Assert.AreEqual(p16, list.Items(3));
            Assert.AreEqual("5: Jarib Boustred (Male), 32 years|1: Farrand Semkins (Female), 77 years|22: Merle Bennet (Female), 42 years|16: Tore Saggs (Male), 28 years", list.ToString());
        }
Ejemplo n.º 2
0
        public void TestInsertLast()
        {
            LinkedLists list = new LinkedLists();

            list.InsertLast(p1);  // p1
            list.InsertLast(p7);  // p1,p7
            list.InsertLast(p13); // p1,p7,p13

            Assert.AreEqual(p1, list.First);
            Assert.AreEqual(p13, list.Last);
            Assert.AreEqual(3, list.Count);

            Assert.AreEqual(p1, list.Items(0));
            Assert.AreEqual(p7, list.Items(1));
            Assert.AreEqual(p13, list.Items(2));
        }
Ejemplo n.º 3
0
        public void TestRemoves()
        {
            LinkedLists list = new LinkedLists();

            list.InsertFirst(p5);  // p5
            list.InsertFirst(p21); // p21,p5
            list.InsertFirst(p9);  // p9,p21,p5
            list.InsertFirst(p24); // p24,p9,p21,p5
            list.RemoveAt(2);      // p24,p9,p5

            Assert.AreEqual(p24, list.First);
            Assert.AreEqual(p5, list.Last);
            Assert.AreEqual(3, list.Count);

            Assert.AreEqual(p24, list.Items(0));
            Assert.AreEqual(p9, list.Items(1));
            Assert.AreEqual(p5, list.Items(2));
        }
Ejemplo n.º 4
0
        public void TestMixedInserts()
        {
            LinkedLists list = new LinkedLists();

            list.InsertFirst(p3); // p3
            list.InsertLast(p22); // p3,p22
            list.InsertFirst(p9); // p9,p3,p22
            list.InsertFirst(p1); // p1,p9,p3,p22
            list.InsertLast(p24); // p1,p9,p3,p22,p24
            list.InsertFirst(p5); // p5,p1,p9,p3,p22,p24
            list.InsertLast(p16); // p5,p1,p9,p3,p22,p24,p16

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

            Assert.AreEqual(p5, list.Items(0));
            Assert.AreEqual(p1, list.Items(1));
            Assert.AreEqual(p9, list.Items(2));
            Assert.AreEqual(p3, list.Items(3));
            Assert.AreEqual(p22, list.Items(4));
            Assert.AreEqual(p24, list.Items(5));
            Assert.AreEqual(p16, list.Items(6));
        }