コード例 #1
0
        public void AddAfter_ShouldAddElements_AtTheEndOfLinkedList(int[] numbers)
        {
            // Arrange
            var linkedList = new SimpleLinkedList(numbers[0]);

            // Act
            for (var i = 1; i < numbers.Length; i++)
            {
                linkedList.AddAfter(numbers[i]);
            }

            var linkedListElements = linkedList.GetElements();

            // Assert
            linkedListElements.ToArray().Should().BeEquivalentTo(numbers);
        }
コード例 #2
0
        public void Reverse_ShouldReverse_TheElementsInLinkedList(int[] numbers)
        {
            // Arrange
            var linkedList     = new SimpleLinkedList(numbers[0]);
            var reverseNumbers = numbers.Reverse();

            // Act
            for (var i = 1; i < numbers.Length; i++)
            {
                linkedList.AddAfter(numbers[i]);
            }

            linkedList.Reverse();
            var linkedListElements = linkedList.GetElements();

            // Assert
            linkedListElements.ToArray().Should().BeEquivalentTo(reverseNumbers);
        }