Exemple #1
0
        public void NumberOfDifferentAuthorsAndChangesForLineThrowsArgumentExceptionIfFilePathIsInvalid()
        {
            var gitCommands = new GitCommands(Mock.Of <ICommandLineExecutor>());

            Action act = () => gitCommands.NumberOfDifferentAuthorsAndChangesForLine(string.Empty, 3);

            act.Should()
            .Throw <ArgumentException>();
        }
Exemple #2
0
        public void NumberOfDifferentAuthorsAndChangesForLine()
        {
            var          executorMock = new Mock <ICommandLineExecutor>();
            var          lineHistory  = Helpers.LoadResource(Paths.GitLineLogOutput, typeof(GitCommandsTest).Assembly);
            const string repoPath     = "dir";
            const string filePath     = "dir/file.js";
            const string gitCommand   = "log --pretty='commit-%h;auth-%an' -L {0},{0}:\"{1}\" --no-patch";
            var          gitCommands  = new GitCommands(executorMock.Object);

            for (var i = 1; i < 4; i++)
            {
                var i1 = i;
                executorMock.Setup(mock => mock.Execute("git", string.Format(gitCommand, i1, filePath), repoPath))
                .Returns(lineHistory.Split('\n'));
            }

            var result = gitCommands.NumberOfDifferentAuthorsAndChangesForLine(filePath, 3)
                         .ToList();

            executorMock.Verify(mock => mock.Execute("git", It.IsAny <string>(), repoPath),
                                Times.Exactly(3));
            result.Should()
            .BeEquivalentTo(new[] { (1, 4, 9), (2, 4, 9), (3, 4, 9) });