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

            Action act = () => gitCommands.NumberOfDifferentAuthorsForFile(string.Empty);

            act.Should()
            .Throw <ArgumentException>();
        }
Exemple #2
0
        public void FileAuthorsTest()
        {
            var fileAuthors  = Helpers.LoadResource(Paths.GitShortlogOutput, typeof(GitCommandsTest).Assembly);
            var executorMock = new Mock <ICommandLineExecutor>();
            var fileName     = "dir/bla.js";
            var gitCommand   = $"shortlog -n -s {fileName}";

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

            var result = gitCommands.NumberOfDifferentAuthorsForFile(fileName);

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