Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 6a3ecae

Browse files
committed
Add tests for matching when target line has changed
1 parent 7f37a14 commit 6a3ecae

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/UnitTests/GitHub.App/Services/NavigationServiceTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,23 @@ public void FindNearestMatchingLine(IList<string> fromLines, IList<string> toLin
2828
Assert.That(matchedLines, Is.EqualTo(expectMatchingLines));
2929
}
3030
}
31+
32+
public class TheFindMatchingLineMethod
33+
{
34+
[TestCase(new[] { "void method()", "code" }, new[] { "void method()", "// code" }, 1, 1)]
35+
[TestCase(new[] { "void method()", "code" }, new[] { "void method()" }, 1, 0, Description = "Keep within bounds")]
36+
[TestCase(new[] { "code" }, new[] { "// code" }, 0, -1)]
37+
[TestCase(new[] { "line", "line" }, new[] { "line", "line" }, 0, 0, Description = "Match nearest line")]
38+
[TestCase(new[] { "line", "line" }, new[] { "line", "line" }, 1, 1, Description = "Match nearest line")]
39+
public void FindNearestMatchingLine(IList<string> fromLines, IList<string> toLines, int line,
40+
int matchingLine)
41+
{
42+
var sp = Substitute.For<IServiceProvider>();
43+
var target = new NavigationService(sp);
44+
45+
var nearestLine = target.FindMatchingLine(fromLines, toLines, line);
46+
47+
Assert.That(nearestLine, Is.EqualTo(matchingLine));
48+
}
49+
}
3150
}

0 commit comments

Comments
 (0)