示例#1
0
        public void AllLinesHistoryTest()
        {
            var lineHistory          = Helpers.LoadResource(Paths.GitLineLogOutput, typeof(GitCommandsTest).Assembly);
            var executorMock         = new Mock <ICommandLineExecutor>();
            var fileName             = "dir/bla.js";
            var gitCommandFirstLine  = $"log --pretty='commit-%h;auth-%an' -L 1,1:\"{fileName}\" --no-patch";
            var gitCommandSecondLine = $"log --pretty='commit-%h;auth-%an' -L 2,2:\"{fileName}\" --no-patch";

            executorMock
            .Setup(mock => mock.Execute("git", It.Is <string>(command => command == gitCommandFirstLine), "dir"))
            .Returns(lineHistory.Split('\n'));
            executorMock
            .Setup(mock => mock.Execute("git", It.Is <string>(command => command == gitCommandSecondLine), "dir"))
            .Returns(lineHistory.Split('\n'));
            var gitCommands = new GitCommands(executorMock.Object);

            var result = gitCommands.NumberOfChangesForEachLine(fileName, 2)
                         .ToArray();

            executorMock.Verify(mock => mock.Execute("git", It.Is <string>(s => s == gitCommandFirstLine), "dir"),
                                Times.Once);
            executorMock.Verify(mock => mock.Execute("git", It.Is <string>(s => s == gitCommandSecondLine), "dir"),
                                Times.Once);
            result.Should()
            .BeEquivalentTo(new[] { 9, 9 });
        }