public void LoopDetectionAlgo_WhenLinkedListIsNonLoop_ReturnNull() { // Arrange var nonLoopLinkedList = new Node(1).AppendToTail(2).AppendToTail(3).AppendToTail(4).AppendToTail(5); // Act var actual = LoopDetection.LoopDetectionAlgo(nonLoopLinkedList); // Assert actual.Should().Be(null); }
public void LoopDetectionAlgo_WhenLoopSizeEqualsToStepsBetweenHeadAndLoopStartingNode_ReturnCorrectLoopStartingNode() { // Arrange var loopStartingNode = new Node(9); var LoopSizeEqualsToStepsBetweenHeadAndLoopStartingNodeLinkedList = new Node(1).AppendToTail(2).AppendToTail(3).AppendToTail(4).AppendToTail(loopStartingNode) .AppendToTail(5).AppendToTail(6).AppendToTail(7).AppendToTail(8).AppendToTail(loopStartingNode); // Act var actual = LoopDetection.LoopDetectionAlgo(LoopSizeEqualsToStepsBetweenHeadAndLoopStartingNodeLinkedList); // Assert Object.ReferenceEquals(actual, loopStartingNode).Should().BeTrue(); }