示例#1
0
        public void Concrete_AddThree_GetFirst()
        {
            StringLinkedList linkedList = new StringLinkedList();

            linkedList.Add("1");
            linkedList.Add("2");
            linkedList.Add("3");

            Assert.AreEqual("1", linkedList.First().Value);
        }
示例#2
0
        public void Concrete_AddFive_GetLast()
        {
            StringLinkedList linkedList = new StringLinkedList();

            linkedList.Add("1");
            linkedList.Add("2");
            linkedList.Add("3");
            linkedList.Add("4");
            linkedList.Add("5");

            Assert.AreEqual("5", linkedList.ElementAt(4).Value);
        }
示例#3
0
        public void Concrete_AddThree_TraverseThree()
        {
            StringLinkedList linkedList = new StringLinkedList();

            linkedList.Add("1");
            linkedList.Add("2");
            linkedList.Add("3");

            Assert.AreEqual("3", linkedList.Head.Value);
            Assert.AreEqual("2", linkedList.Head.Next.Value);
            Assert.AreEqual("1", linkedList.Head.Next.Next.Value);
        }
示例#4
0
        public void Concrete_AddFive_InsertBetween_3And4()
        {
            StringLinkedList linkedList = new StringLinkedList();

            linkedList.Add("1");
            linkedList.Add("2");
            linkedList.Add("3");
            linkedList.Add("4");
            linkedList.Add("5");

            linkedList.Insert("x", 3);

            Assert.AreEqual("1", linkedList.ElementAt(0).Value);
            Assert.AreEqual("2", linkedList.ElementAt(1).Value);
            Assert.AreEqual("3", linkedList.ElementAt(2).Value);
            Assert.AreEqual("x", linkedList.ElementAt(3).Value);
            Assert.AreEqual("4", linkedList.ElementAt(4).Value);
            Assert.AreEqual("5", linkedList.ElementAt(5).Value);
        }
示例#5
0
        public void Concrete_AddNone_GetFirst_ReturnsNull()
        {
            StringLinkedList linkedList = new StringLinkedList();

            Assert.IsNull(linkedList.First());
        }
示例#6
0
        public void Concrete_AddOne_Insert()
        {
            StringLinkedList linkedList = new StringLinkedList();

            linkedList.Add("1");

            linkedList.Insert("x", 0);

            Assert.AreEqual("x", linkedList.ElementAt(0).Value);
            Assert.AreEqual("1", linkedList.ElementAt(1).Value);
        }