Ejemplo n.º 1
0
        public void InsertedBeforeHeadNode_ShouldBecomeTheHeadOfList()
        {
            var list = new DblLinkedList <int>();

            list.InsertHead(DblLinkedList.CreateNode(1));
            var newNode = DblLinkedList.CreateNode(3);

            list.InsertBefore(list.Head, newNode);
            list.Head.Value.Should().Be(newNode.Value);
        }
Ejemplo n.º 2
0
        public void IterativeInsertBeforeHead_ShouldProduceCorrectList(IList <int> input)
        {
            var list = new DblLinkedList <int>();

            foreach (var i in input.Reverse())
            {
                list.InsertBefore(list.Head, DblLinkedList.CreateNode(i));
            }
            VerifyList(list, input);
        }
Ejemplo n.º 3
0
        public void IterativeInsertBefore_ShouldProduceCorrectList()
        {
            var input       = new string[] { "1", "2", "3" };
            var list        = new DblLinkedList <string>();
            var currentNode = list.Head;

            foreach (var i in input.Reverse())
            {
                currentNode = list.InsertBefore(currentNode, DblLinkedList.CreateNode(i));
            }
            VerifyList(list, input);
        }
Ejemplo n.º 4
0
        public void InsertedBeforeNode_ShouldBeInsertedInsertedInRightPlace()
        {
            var list  = new DblLinkedList <int>();
            var node1 = DblLinkedList.CreateNode(1);
            var node2 = DblLinkedList.CreateNode(2);

            list.InsertHead(node1);
            list.InsertHead(node2);
            var newNode = DblLinkedList.CreateNode(3);

            list.InsertBefore(node1, newNode);
            list.Head.Next.Value.Should().Be(newNode.Value);
        }