public void ShouldNotTakeVersionFromNameOfNonReleaseBranch(string branchName)
        {
            using var fixture = new EmptyRepositoryFixture();
            fixture.Repository.MakeACommit();
            var branch = fixture.Repository.CreateBranch(branchName);
            var sut    = new VersionInBranchNameVersionStrategy();

            var gitVersionContext = new GitVersionContext(fixture.Repository, new NullLog(), branch, new Config().ApplyDefaults());
            var baseVersions      = sut.GetVersions(gitVersionContext);

            baseVersions.ShouldBeEmpty();
        }
        public void CanTakeVersionFromNameOfReleaseBranch(string branchName, string expectedBaseVersion)
        {
            using var fixture = new EmptyRepositoryFixture();
            fixture.Repository.MakeACommit();
            var branch = fixture.Repository.CreateBranch(branchName);
            var sut    = new VersionInBranchNameVersionStrategy();

            var gitVersionContext = new GitVersionContext(fixture.Repository, new NullLog(), branch, new Config().ApplyDefaults());
            var baseVersion       = sut.GetVersions(gitVersionContext).Single();

            baseVersion.SemanticVersion.ToString().ShouldBe(expectedBaseVersion);
        }
        public void CanTakeVersionFromNameOfRemoteReleaseBranch(string branchName, string expectedBaseVersion)
        {
            using var fixture = new RemoteRepositoryFixture();
            var branch = fixture.Repository.CreateBranch(branchName);

            Commands.Checkout(fixture.Repository, branch);
            fixture.MakeACommit();

            Commands.Fetch((Repository)fixture.LocalRepositoryFixture.Repository, fixture.LocalRepositoryFixture.Repository.Network.Remotes.First().Name, new string[0], new FetchOptions(), null);
            fixture.LocalRepositoryFixture.Checkout($"origin/{branchName}");

            var sut = new VersionInBranchNameVersionStrategy();
            var gitVersionContext = new GitVersionContext(fixture.Repository, new NullLog(), branch, new Config().ApplyDefaults());
            var baseVersion       = sut.GetVersions(gitVersionContext).Single();

            baseVersion.SemanticVersion.ToString().ShouldBe(expectedBaseVersion);
        }
        public void CanTakeVersionFromNameOfConfiguredReleaseBranch(string branchName, string expectedBaseVersion)
        {
            using var fixture = new EmptyRepositoryFixture();
            fixture.Repository.MakeACommit();
            var branch        = fixture.Repository.CreateBranch(branchName);
            var sut           = new VersionInBranchNameVersionStrategy();
            var branchConfigs = new Dictionary <string, BranchConfig> {
                { "support", new BranchConfig {
                      IsReleaseBranch = true
                  } }
            };
            var config = new Config {
                Branches = branchConfigs
            }.ApplyDefaults();

            var gitVersionContext = new GitVersionContext(fixture.Repository, new NullLog(), branch, config);
            var baseVersion       = sut.GetVersions(gitVersionContext).Single();

            baseVersion.SemanticVersion.ToString().ShouldBe(expectedBaseVersion);
        }