public void WhenTwoNodesAreInsertedBefore_ThenValuesAreLinkedLIFO() { var firstNode = new DoublyLinkedNode <int>(1); var secondValue = 2; var thirdValue = 3; firstNode.LinkBefore(thirdValue); firstNode.LinkBefore(secondValue); firstNode.Previous.Value.Should().Be(secondValue); firstNode.Previous.Previous.Value.Should().Be(thirdValue); }
public void WhenNodeIsInsertedBefore_TheNewNodeNextIsFirstNode() { var firstNode = new DoublyLinkedNode <int>(1); var secondNode = firstNode.LinkBefore(2); secondNode.Next.Should().Be(firstNode); }
public void WhenNewNodeInsertedBefore_ThenFirstNodeHasNextReference() { var firstNode = new DoublyLinkedNode <int>(1); var secondValue = 2; firstNode.LinkBefore(secondValue); firstNode.Previous.Value.Should().Be(secondValue); }
public void WhenNodeIsReplaced_ThenItsPreviousAndNextReferToTheReplacement() { var firstNode = new DoublyLinkedNode <int>(2); var previous = firstNode.LinkBefore(1); var next = firstNode.LinkAfter(3); var replacement = firstNode.Replace(5); previous.Next.Value.Should().Be(5); next.Previous.Value.Should().Be(5); replacement.Previous.Should().Be(previous); replacement.Next.Should().Be(next); }