public void TestTraversalCallback()
        {
            var sut = new SungLinkedList <int>();

            sut.Append(1);
            sut.Append(2);
            sut.Append(3);

            int[] expected = { 1, 2, 3 };
            Assert.True(expected.SequenceEqual(sut.Traverse((curr, last) => false).Select(n => n.Value)));
            Assert.Empty(sut.Traverse((curr, last) => true));
        }
        public void TestRemovingFirstAndLast()
        {
            var sut = new SungLinkedList <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 void TestInsertAndTraversal()
        {
            // Arrange
            var sut = new SungLinkedList <int>();

            sut.Append(1);
            sut.Append(2);
            sut.Append(3);

            // Act
            var actual = sut.Traverse().Select(node => node.Value);

            // Assert
            int[] expected = { 1, 2, 3 };
            Assert.True(expected.SequenceEqual(actual));
        }
        public void TestRemoving()
        {
            // Arrange
            var sut = new SungLinkedList <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 TestInsertAt()
        {
            // Arrange
            var sut = new SungLinkedList <int>();

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

            sut.Append(3);

            // Act: Insert at 2
            sut.InsertAt(node, 10);

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

            Assert.True(expected.SequenceEqual(actual));
        }