Ejemplo n.º 1
0
        public void NumberOfCommitsOnCurrentBranchTest()
        {
            var          executorMock = new Mock <ICommandLineExecutor>();
            const string repoPath     = "dir";
            const string gitCommand   = "rev-list --count HEAD";

            executorMock.Setup(mock => mock.Execute("git", It.Is <string>(command => command == gitCommand), repoPath))
            .Returns(new[] { "123" });
            var gitCommands = new GitCommands(executorMock.Object);

            var result = gitCommands.NumberOfCommitsOnCurrentBranch(repoPath);

            executorMock.Verify(mock => mock.Execute("git", gitCommand, repoPath), Times.Once);
            result.Should()
            .Be(123);
        }