예제 #1
0
        public void Can_Add_First()
        {
            var myLinkedList = new MyLinkedList <int>();

            myLinkedList.AddFirst(1);
            myLinkedList.GetHead().Data.Should().Be(1);
        }
예제 #2
0
        public void Can_Add_Last()
        {
            var myLinkedList = new MyLinkedList <int>();

            myLinkedList.AddLast(1);
            myLinkedList.AddLast(2);
            myLinkedList.AddFirst(3);
            myLinkedList.GetLast().Data.Should().Be(2);
        }
예제 #3
0
        public void Can_Add_Before()
        {
            var myLinkedList = new MyLinkedList <int>();

            myLinkedList.AddFirst(1);
            myLinkedList.AddLast(3);
            myLinkedList.AddLast(4);
            myLinkedList.AddBefore(myLinkedList.GetHead().Next, 2);
            myLinkedList.GetHead().Next.Data.Should().Be(2);
        }
예제 #4
0
        public void Can_Add_After()
        {
            var myLinkedList = new MyLinkedList <int>();

            myLinkedList.AddFirst(1);
            myLinkedList.AddLast(2);
            myLinkedList.AddLast(4);
            myLinkedList.AddAfter(myLinkedList.GetHead().Next, 3);
            myLinkedList.GetHead().Next.Next.Data.Should().Be(3);
        }
예제 #5
0
        public void Can_Travel_All()
        {
            var myLinkedList = new MyLinkedList <int>();

            myLinkedList.AddFirst(1);
            myLinkedList.AddLast(2);
            myLinkedList.AddLast(3);

            var list = myLinkedList.ToList();

            list[0].Should().Be(1);
            list[1].Should().Be(2);
            list[2].Should().Be(3);
            list.Count.Should().Be(3);
        }