public void CanBumpAndSerializeStringVersion(string version, VersionBump bump, string expectedVersion)
        {
            var semver = SemVer.FromString(version);

            semver.Bump(bump);

            Assert.Equal(semver.ToVersionString(), expectedVersion);
        }
        public void CanBumpVersions(string version, VersionBump bump, int expectedMajor, int expectedMinor, int expectedPatch)
        {
            var semver = SemVer.FromString(version);

            semver.Bump(bump, version);

            Assert.Equal(expectedMajor, semver.Major);
            Assert.Equal(expectedMinor, semver.Minor);
            Assert.Equal(expectedPatch, semver.Patch);
        }
        public void Respects_custom_pre_release_prefix(
            string version,
            VersionBump bump,
            string expectedVersion,
            string prefix
            )
        {
            var semver = _bumper.Bump(SemVer.FromString(version), bump, preReleasePrefix: prefix);

            Assert.Equal(expectedVersion, semver.ToSemVerVersionString());
        }
        public void GetVersionBumpFromRemaingArgsWork(string strVersionBump, VersionBump expectedBump)
        {
            var args = Program.GetVersionBumpFromRemainingArgs(new List <string>()
            {
                strVersionBump
            }, OutputFormat.Text, true, true);

            Assert.Equal(expectedBump, args.VersionBump);
            if (expectedBump == VersionBump.Specific)
            {
                Assert.Equal(strVersionBump, args.SpecificVersionToApply);
            }
        }
        /// <summary>
        /// Bump the currently parsed version information with the specified <paramref name="bump"/>
        /// </summary>
        /// <param name="bump">The bump to apply to the version</param>
        /// <param name="specificVersionToApply">The specific version to apply if bump is Specific</param>
        public void Bump(VersionBump bump, string specificVersionToApply = "")
        {
            switch (bump)
            {
            case VersionBump.Major:
            {
                Major += 1;
                Minor  = 0;
                Patch  = 0;
                break;
            }

            case VersionBump.Minor:
            {
                Minor += 1;
                Patch  = 0;
                break;
            }

            case VersionBump.Patch:
            {
                Patch += 1;
                break;
            }

            case VersionBump.Specific:
            {
                if (string.IsNullOrEmpty(specificVersionToApply))
                {
                    throw new ArgumentException($"When bump is specific, specificVersionToApply must be provided");
                }
                var specific = SemVer.FromString(specificVersionToApply);
                Major = specific.Major;
                Minor = specific.Minor;
                Patch = specific.Patch;
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException($"VersionBump : {bump} not supported");
            }
            }
        }
        public void CanBumpVersions(
            string version,
            VersionBump bump,
            int expectedMajor,
            int expectedMinor,
            int expectedPatch,
            string expectedPreRelease,
            string expectedBuildMeta
            )
        {
            var semver = _bumper.Bump(
                SemVer.FromString(version),
                bump,
                version
                );

            Assert.Equal(expectedMajor, semver.Major);
            Assert.Equal(expectedMinor, semver.Minor);
            Assert.Equal(expectedPatch, semver.Patch);
            Assert.Equal(expectedPreRelease, semver.PreRelease);
            Assert.Equal(expectedBuildMeta, semver.BuildMeta);
        }
Exemple #7
0
        /// <summary>
        /// Bump the currently parsed version information with the specified <paramref name="bump"/>
        /// </summary>
        /// <param name="currentVersion"></param>
        /// <param name="bump">The bump to apply to the version</param>
        /// <param name="specificVersionToApply">The specific version to apply if bump is Specific</param>
        /// <param name="buildMeta">Additional build metadata to add to the final version string</param>
        /// <param name="preReleasePrefix">Override of default `next` pre-release prefix/label</param>
        public SemVer Bump(
            SemVer currentVersion,
            VersionBump bump,
            string specificVersionToApply = "",
            string buildMeta        = "",
            string preReleasePrefix = ""
            )
        {
            var newVersion = SemVer.FromString(currentVersion.ToSemVerVersionString());

            newVersion.BuildMeta = buildMeta;

            switch (bump)
            {
            case VersionBump.Major:
            {
                HandleMajorBump(newVersion);
                break;
            }

            case VersionBump.PreMajor:
            {
                HandlePreMajorBump(newVersion, preReleasePrefix);
                break;
            }

            case VersionBump.Minor:
            {
                HandleMinorBump(newVersion);
                break;
            }

            case VersionBump.PreMinor:
            {
                HandlePreMinorBump(newVersion, preReleasePrefix);
                break;
            }

            case VersionBump.Patch:
            {
                HandlePatchBump(newVersion);
                break;
            }

            case VersionBump.PrePatch:
            {
                HandlePrePatchBump(newVersion, preReleasePrefix);
                break;
            }

            case VersionBump.PreRelease:
            {
                HandlePreReleaseBump(newVersion);
                break;
            }

            case VersionBump.Specific:
            {
                HandleSpecificVersion(specificVersionToApply, newVersion);
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(bump), $"VersionBump : {bump} not supported");
            }
            }

            return(newVersion);
        }
        public void CanBumpAndSerializeStringVersion(string version, VersionBump bump, string expectedVersion)
        {
            var semver = _bumper.Bump(SemVer.FromString(version), bump);

            Assert.Equal(expectedVersion, semver.ToSemVerVersionString());
        }