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

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

            act.Should()
            .Throw <ArgumentException>();
        }
Beispiel #2
0
        public void FileHistoryTest()
        {
            var gitLogOutput =
                Helpers.LoadResource(Paths.GitPrettyLogOutput, typeof(GitCommandsTest).Assembly);
            var executorMock = new Mock <ICommandLineExecutor>();
            var fileName     = "dir/bla.js";
            var gitCommand   = $"log --pretty=oneline {fileName}";

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

            var result = gitCommands.NumberOfChangesForFile(fileName);

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