public void TestInsertAt() { // Arrange var sut = new DoublySungLinkedList <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)); }
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); }