public void NumberOfChangesForLineThrowsArgumentExceptionIfFilePathIsInvalid() { var gitCommands = new GitCommands(Mock.Of <ICommandLineExecutor>()); Action act = () => gitCommands.NumberOfChangesForLine(string.Empty, 2); act.Should() .Throw <ArgumentException>(); }
public void SingleLineHistoryTest() { var lineHistory = Helpers.LoadResource(Paths.GitLineLogOutput, typeof(GitCommandsTest).Assembly); var executorMock = new Mock <ICommandLineExecutor>(); var fileName = "dir/bla.js"; var lineNumber = 2; var gitCommand = $"log --pretty='commit-%h;auth-%an' -L {lineNumber},{lineNumber}:\"{fileName}\" --no-patch"; executorMock.Setup(mock => mock.Execute("git", It.Is <string>(command => command == gitCommand), "dir")) .Returns(lineHistory.Split('\n')); var gitCommands = new GitCommands(executorMock.Object); var result = gitCommands.NumberOfChangesForLine(fileName, lineNumber); executorMock.Verify(mock => mock.Execute("git", It.Is <string>(s => s == gitCommand), "dir"), Times.Once); result.Should() .Be(9); }