コード例 #1
0
        public async Task ChangeMajorVersionTest()
        {
            using (var fs = new DisposableFileSystem())
            {
                fs.CreateFile("MySolution.sln");
                fs.CreateFolder("src/Services");
                fs.CreateFile("src/Services/project1.csproj", ProjectHelper.SetVersion("1.5.1"));
                var store   = new ProjectStore();
                var command = new MajorCommand(GitHelper.CreateDefaultGitMock().Object);
                var context = new CommandContext(_console, Verbosity.Info);
                context.Directory = fs.RootPath;

                await command.ExecuteAsync(context);

                var project = store.Read(PathHelper.GetFile(fs, "src/Services/project1.csproj"));

                Assert.Equal("2.0.0", project.Version);
            }
        }
コード例 #2
0
        public async Task CreateCommitTest()
        {
            using (var fs = new DisposableFileSystem())
            {
                fs.CreateFile("MySolution.sln");
                fs.CreateFolder("src/Services");
                fs.CreateFile("src/Services/project1.csproj", ProjectHelper.SetVersion("1.5.1"));
                var store   = new ProjectStore();
                var gitMock = GitHelper.CreateGitMock(true);

                var command = new MajorCommand(gitMock.Object);
                var context = new CommandContext(_console, Verbosity.Info);
                context.Directory = fs.RootPath;
                context.Message   = "test";

                await command.ExecuteAsync(context);

                gitMock.Verify(git => git.IsInstalled());
                gitMock.Verify(git => git.RunCommandAsync(It.IsAny <CommandContext>(), It.Is <string>(args => args.Equals("commit -a -m \"test\""))));
            }
        }
コード例 #3
0
        public async Task ChangeVersionWithoutNoGitToolTest()
        {
            using (var fs = new DisposableFileSystem())
            {
                fs.CreateFile("MySolution.sln");
                fs.CreateFolder("src/Services");
                fs.CreateFile("src/Services/project1.csproj", ProjectHelper.SetVersion("1.5.1"));
                var store   = new ProjectStore();
                var command = new MajorCommand(GitHelper.CreateDefaultGitMock().Object);
                var context = new CommandContext(_console, Verbosity.Info);
                context.Directory = fs.RootPath;
                context.Message   = "test";

                var exception = await Assert.ThrowsAsync <InvalidOperationException>(() => command.ExecuteAsync(context));

                Assert.Equal("Unable to commit because git is not installed.", exception.Message);
            }
        }