Beispiel #1
0
        public static Task <int> Main(string[] args)
        {
            var command = new RootCommand()
            {
                Description = "Developer tool to update the Visual Studio project versions."
            };

            command.AddCommand(ListCommand.Create());
            command.AddCommand(MajorCommand.Create());
            command.AddCommand(MinorCommand.Create());
            command.AddCommand(PatchCommand.Create());
            command.AddCommand(BuildCommand.Create());
            command.AddCommand(PreCommand.Create());
            command.AddCommand(SetCommand.Create());


            var builder = new CommandLineBuilder(command)
                          .UseHelp()
                          .UseDefaults()
                          .UseVersionOption()
                          .CancelOnProcessTermination()
                          .UseExceptionHandler();

            var parser = builder.Build();

            return(parser.InvokeAsync(args));
        }
Beispiel #2
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);
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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\""))));
            }
        }