public VersionCliTest()
        {
            _vcsTool = A.Fake <IVcs>(opts => opts.Strict());
            A.CallTo(() => _vcsTool.ToolName()).Returns("_FAKE_");

            _fileDetector = A.Fake <ProjectFileDetector>();
            _fileParser   = A.Fake <ProjectFileParser>();
            _filePatcher  = A.Fake <ProjectFileVersionPatcher>();

            A.CallTo(() => _fileDetector.FindAndLoadCsProj(A <string> ._)).Returns("<Project/>");
            const string csProjFilePath = "/unit-test/test.csproj";

            A.CallTo(() => _fileDetector.ResolvedCsProjFile).Returns(csProjFilePath);

            A.CallTo(() => _fileParser.Load(A <string> ._)).DoesNothing();
            A.CallTo(() => _fileParser.Version).Returns("1.2.1");

            _cli = new VersionCli(
                _vcsTool,
                _fileDetector,
                _fileParser,
                _filePatcher,
                new SemVerBumper()
                );
        }
        public VersionInfo Execute(VersionCliArgs args)
        {
            if (!args.DryRun && args.DoVcs && !_vcsTool.IsVcsToolPresent())
            {
                throw new OperationCanceledException(
                          $"Unable to find the vcs tool {_vcsTool.ToolName()} in your path");
            }

            if (!args.DryRun && args.DoVcs && !_vcsTool.IsRepositoryClean())
            {
                throw new OperationCanceledException(
                          "You currently have uncomitted changes in your repository, please commit these and try again");
            }

            var csProjXml = _fileDetector.FindAndLoadCsProj(args.CsProjFilePath);

            _fileParser.Load(csProjXml);

            var semVer = SemVer.FromString(_fileParser.Version);

            semVer.Bump(args.VersionBump, args.SpecificVersionToApply);
            var newVersion = semVer.ToVersionString();

            if (!args.DryRun) // if we are not in dry run mode, then we should go ahead
            {
                var patchedCsProjXml = _fileVersionPatcher.Patch(
                    csProjXml,
                    _fileParser.Version,
                    newVersion
                    );
                _fileVersionPatcher.Flush(
                    patchedCsProjXml,
                    _fileDetector.ResolvedCsProjFile
                    );

                if (args.DoVcs)
                {
                    // Run git commands
                    _vcsTool.Commit(_fileDetector.ResolvedCsProjFile, $"v{newVersion}");
                    _vcsTool.Tag($"v{newVersion}");
                }
            }

            var theOutput = new VersionInfo
            {
                Product = new ProductOutputInfo
                {
                    Name    = ProductInfo.Name,
                    Version = ProductInfo.Version
                },
                OldVersion      = _fileParser.Version,
                NewVersion      = newVersion,
                ProjectFile     = _fileDetector.ResolvedCsProjFile,
                VersionStrategy = args.VersionBump.ToString().ToLowerInvariant()
            };


            if (args.OutputFormat == OutputFormat.Json)
            {
                WriteJsonToStdout(theOutput);
            }
            else
            {
                Console.WriteLine($"Bumped {_fileDetector.ResolvedCsProjFile} to version {newVersion}");
            }

            return(theOutput);
        }