public void TestRemovingFirstAndLast()
        {
            var sut = new DoublySungLinkedList <int>();
            var a   = sut.Append(1);
            var b   = sut.Append(2);
            var c   = sut.Append(3);

            sut.Remove(a);
            Assert.True(new[] { 2, 3 }.SequenceEqual(sut.Traverse().Select(node => node.Value)));

            sut.Remove(c);
            Assert.True(new[] { 2 }.SequenceEqual(sut.Traverse().Select(node => node.Value)));
        }
        public T Pop()
        {
            if (_count == 0)
            {
                throw new InvalidOperationException("Stack empty.");
            }

            _count--;
            var result = _list.Head.Value;

            _list.Remove(_list.Head);

            return(result);
        }
        public void TestRemoving()
        {
            // Arrange
            var sut = new DoublySungLinkedList <int>();

            sut.Append(1);
            var node = sut.Append(2);

            sut.Append(3);

            // Act: Remove 2.
            sut.Remove(node);

            // Assert
            int[] expected = { 1, 3 };
            var   actual   = sut.Traverse().Select(n => n.Value);

            Assert.True(expected.SequenceEqual(actual));
        }
        public void TestPreviousNode()
        {
            var sut = new DoublySungLinkedList <int>();

            sut.Append(1);
            var node  = sut.Append(2);
            var node2 = sut.Append(3);

            // Test append
            Assert.True(node.Previous.Value == 1);

            // Test remove
            sut.Remove(node);
            Assert.True(node2.Previous.Value == 1);

            // Test insertAt
            var newNode = sut.InsertAt(node2, 5);

            Assert.True(newNode.Previous.Value == 3);
        }