Example #1
0
        public void IncreaseVersion_ShouldIncreaseMajorVersion_WhenVersionIsValid()
        {
            var version = new VersionChanger("1");

            version.IncreaseVersion(VersionPart.Major);
            version.Version.Should().Be("2");
        }
Example #2
0
        /// <summary>Defines the method that determines whether the command can execute in its current state.</summary>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to <see langword="null" />.</param>
        /// <returns>
        /// <see langword="true" /> if this command can be executed; otherwise, <see langword="false" />.</returns>
        public bool CanExecute(object parameter)
        {
            var version = parameter.As <ProjectViewModel>().IsNotNull(p => p.AssemblyInfoVersion)
                          .IsNotNull(p => p.Version);

            return(!string.IsNullOrEmpty(version) && VersionChanger.TryParse(version, out VersionChanger oldVersion));
        }
Example #3
0
        public void DecreaseVersion_ShouldDecreaseMinorVersion_WhenVersionIsValid()
        {
            var version = new VersionChanger("1.1");

            version.DecreaseVersion(VersionPart.Minor);
            version.Version.Should().Be("1.0");
        }
Example #4
0
        public void DecreaseVersion_ShouldNotDecreaseBuildVersion_WhenVersionWouldBeLowerThanZero()
        {
            var version = new VersionChanger("1.0.0.0");

            version.DecreaseVersion(VersionPart.Build);
            version.Version.Should().Be("1.0.0.0");
        }
Example #5
0
        public void DecreaseVersion_ShouldNotDecreaseBuildVersion_WhenBuildIsAsterisk()
        {
            var version = new VersionChanger("1.0.0.*");

            version.IncreaseVersion(VersionPart.Build);
            version.Version.Should().Be("1.0.0.*");
        }
Example #6
0
        public void IncreaseVersion_ShouldIncreaseRevisionVersion_WhenVersionContainsAllPartsWithAsterisk()
        {
            var version = new VersionChanger("1.0.0.*");

            version.IncreaseVersion(VersionPart.Revision);
            version.Version.Should().Be("1.0.1.*");
        }
Example #7
0
        public void DecreaseVersion_ShouldDecreaseBuildVersion_WhenVersionIsValid()
        {
            var version = new VersionChanger("1.0.0.1");

            version.DecreaseVersion(VersionPart.Build);
            version.Version.Should().Be("1.0.0.0");
        }
Example #8
0
        public void DecreaseVersion_ShouldNotDecreaseRevisionVersion_WhenRevisionIsAsterisk()
        {
            var version = new VersionChanger("1.0.*");

            version.DecreaseVersion(VersionPart.Revision);
            version.Version.Should().Be("1.0.*");
        }
Example #9
0
        public void IncreaseVersion_ShouldIncreaseRevisionVersion_WhenVersionIsValid()
        {
            var version = new VersionChanger("1.0.0");

            version.IncreaseVersion(VersionPart.Revision);
            version.Version.Should().Be("1.0.1");
        }
Example #10
0
        public void IncreaseVersion_ShouldIncreaseMinorVersion_WhenVersionContainsAllParts()
        {
            var version = new VersionChanger("1.0.0.0");

            version.IncreaseVersion(VersionPart.Minor);
            version.Version.Should().Be("1.1.0.0");
        }
Example #11
0
        public void DecreaseVersion_ShouldNotDecreaseMajorVersion_WhenVersionWouldBeLowerThanZero()
        {
            var version = new VersionChanger("0");

            version.DecreaseVersion(VersionPart.Major);
            version.Version.Should().Be("0");
        }
Example #12
0
 public void ParseFromString_When3PartsUsedAndRevisionHasAsteriskUsed_ShouldIdentifyAllPartsCorrectly()
 {
     VersionChanger.ParseFromString("1.2.*", out int major, out int minor, out int revision, out int build);
     major.Should().Be(1);
     minor.Should().Be(2);
     revision.Should().Be(int.MaxValue);
     build.Should().Be(-1);
 }
Example #13
0
 public void ParseFromString_WhenAllPartsUsed_ShouldIdentifyAllPartsCorrectly()
 {
     VersionChanger.ParseFromString("1.2.3.4", out int major, out int minor, out int revision, out int build);
     major.Should().Be(1);
     minor.Should().Be(2);
     revision.Should().Be(3);
     build.Should().Be(4);
 }
Example #14
0
 public void ParseFromString_WhenVersionsAbove9Used_ShouldIdentifyAllPartsCorrectly()
 {
     VersionChanger.ParseFromString("10.20.30.40", out int major, out int minor, out int revision, out int build);
     major.Should().Be(10);
     minor.Should().Be(20);
     revision.Should().Be(30);
     build.Should().Be(40);
 }
Example #15
0
 public void ParseFromString_When1PartUsed_ShouldIdentify1PartCorrectly()
 {
     VersionChanger.ParseFromString("1", out int major, out int minor, out int revision, out int build);
     major.Should().Be(1);
     minor.Should().Be(-1);
     revision.Should().Be(-1);
     build.Should().Be(-1);
 }
Example #16
0
        /// <summary>Defines the method to be called when the command is invoked.</summary>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to <see langword="null" />.</param>
        public void Execute(object parameter)
        {
            var assemblyInfo = parameter.As <ProjectViewModel>().IsNotNull(p => p.AssemblyInfoVersion);

            if (!VersionChanger.TryParse(assemblyInfo.Version, out VersionChanger version))
            {
                return;
            }

            version.DecreaseVersion(VersionPart.Major);

            assemblyInfo.Version = version.Version;
        }
        /// <summary>Defines the method that determines whether the command can execute in its current state.</summary>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to <see langword="null" />.</param>
        /// <returns>
        /// <see langword="true" /> if this command can be executed; otherwise, <see langword="false" />.</returns>
        public bool CanExecute(object parameter)
        {
            var version = parameter.As <ProjectViewModel>().IsNotNull(p => p.AssemblyInfoVersion)
                          .IsNotNull(p => p.Version);

            if (string.IsNullOrEmpty(version))
            {
                return(false);
            }

            VersionChanger.ParseFromString(version, out int major, out int minor, out int revision, out int build);

            return(!string.IsNullOrEmpty(version) && major != -1 && minor != -1 && revision != -1);
        }
        /// <summary>Defines the method to be called when the command is invoked.</summary>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to <see langword="null" />.</param>
        public void Execute(object parameter)
        {
            var assemblyInfo = parameter.As <ProjectViewModel>().IsNotNull(p => p.AssemblyInfoVersion);

            if (!VersionChanger.TryParse(assemblyInfo.Version, out VersionChanger version))
            {
                return;
            }

            VersionChanger.ParseFromString(assemblyInfo.Version, out int major, out int minor, out int revision, out int build);

            if (build == -1)
            {
                build = int.MaxValue;
            }
            else if (build == int.MaxValue)
            {
                build = -1;
            }

            assemblyInfo.Version = VersionChanger.ToString(major, minor, revision, build);
        }
Example #19
0
 public void TryParse_WhenMajorContainsAsterisk_ShouldReturnFalse()
 {
     VersionChanger.TryParse("*", out VersionChanger version).Should().BeFalse();
 }
Example #20
0
 public void TryParse_WhenValidBuildWithAsteriskVersionGiven_ShouldReturnTrue()
 {
     VersionChanger.TryParse("1.0.0.*", out VersionChanger version).Should().BeTrue();
 }
Example #21
0
 public void TryParse_WhenRevisionAndBuildContainsAsterisk_2ndAsteriskShouldBeIgnored()
 {
     VersionChanger.TryParse("1.0.*.*", out VersionChanger version);
     version.Version.Should().Be("1.0.*");
 }
Example #22
0
 public void TryParse_WhenValidMajorVersionGiven_ShouldReturnTrue()
 {
     VersionChanger.TryParse("1", out VersionChanger version).Should().BeTrue();
 }
Example #23
0
 public void TryParse_WhenMajorIsInValidButMinorIsNot_ShouldReturnFalse()
 {
     VersionChanger.TryParse("X.0", out VersionChanger version).Should().BeFalse();
 }
Example #24
0
 public void TryParse_WhenMajorIsValidButMinorIsNot_ShouldReturnTrue()
 {
     VersionChanger.TryParse("1.X", out VersionChanger version).Should().BeTrue();
 }
Example #25
0
 public void TryParse_WhenRevisionIsValidButBuildIsNot_ShouldReturnTrue()
 {
     VersionChanger.TryParse("1.0.X", out VersionChanger version).Should().BeTrue();
 }