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

            Action act = () => gitCommands.NumberOfDifferentAuthorForLine(string.Empty, 1);

            act.Should()
            .Throw <ArgumentException>();
        }
예제 #2
0
        public void LineAuthorsTest()
        {
            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.NumberOfDifferentAuthorForLine(fileName, lineNumber);

            executorMock.Verify(mock => mock.Execute("git", It.Is <string>(s => s == gitCommand), "dir"), Times.Once);
            result.Should()
            .Be(4);
        }