public void FixedBehaviour_DoesNotIncrement()
        {
            var    sut    = new CompleteVersion(new VersionUnit("2"), new VersionUnit("0", "."));
            string before = sut.GetVersionString(DisplayType.Full);

            sut.Increment();
            Assert.Equal(before, sut.GetVersionString(DisplayType.Full)); //, "Digits should be fixed and not change when incremented");
        }
        public void DisplayType_DefaultsToFull()
        {
            var sut = new CompleteVersion(
                new VersionUnit("1", ""),
                new VersionUnit("0", "."),
                new VersionUnit("1", "."),
                new VersionUnit("0", ".", DigitIncremementBehaviour.AutoIncrementWithResetAny));

            Assert.Equal(sut.GetVersionString(DisplayType.Full), sut.GetVersionString()); //, "The default should be to display as full");
        }
        public void VersionStorage_Json_Loads()
        {
            string fn  = uth.NewTemporaryFileName(true);
            var    sut = new JsonVersionPersister(fn);
            var    cv  = new CompleteVersion(new VersionUnit("1", ".", DigitIncremementBehaviour.ContinualIncrement), new VersionUnit("Alpha", "-"), new VersionUnit("1"), new VersionUnit("1", "", DigitIncremementBehaviour.ContinualIncrement));

            sut.Persist(cv);

            var cv2 = sut.GetVersion();

            Assert.Equal(cv.GetVersionString(), cv2.GetVersionString()); //, "The loaded type was not the same as the saved one, values");
            cv.Increment(); cv2.Increment();
            Assert.Equal(cv.GetVersionString(), cv2.GetVersionString()); //, "The loaded type was not the same as the saved one, behaviours");
        }
        public void UseCase_Plisky_Works()
        {
            var sut = new CompleteVersion(new VersionUnit("2"), new VersionUnit("0", "."),
                                          new VersionUnit("Unicorn", "-"),
                                          new VersionUnit("0", ".", DigitIncremementBehaviour.ContinualIncrement));
            var verString = sut.GetVersionString();

            Assert.Equal("2.0-Unicorn.0", verString); //,"The initial string is not correct");
            sut.Increment();
            verString = sut.GetVersionString();
            Assert.Equal("2.0-Unicorn.1", verString); //, "The first increment string is not correct");
            sut.Increment();
            verString = sut.GetVersionString(DisplayType.Full);
            Assert.Equal("2.0-Unicorn.2", verString); //, "The second increment string is not correct");
        }
示例#5
0
        private static void CreateNewVersionStore()
        {
            string startVer = "0.0.0.0";

            if (!string.IsNullOrEmpty(options.QuickValue))
            {
                Console.WriteLine($"Using Value From Command Line: {options.QuickValue}");
                startVer = options.QuickValue;
            }
            if (!string.IsNullOrEmpty(options.QuickValue))
            {
                Console.WriteLine($"Setting Release From Command Line: {options.Release}");
            }
            Console.WriteLine($"Creating New Version Store: {startVer}");

            CompleteVersion cv = new CompleteVersion(startVer);

            versionerUsed = cv;

            cv.ReleaseName = options.Release;
            VersionStorage vs = new JsonVersionPersister(options.VersionPersistanceValue);

            Console.WriteLine($"Saving {cv.GetVersionString()}");
            vs.Persist(cv);
        }
示例#6
0
        public void GetVersionString_Short_ShowsCorrect()
        {
            var sut = new CompleteVersion(new VersionUnit("1"), new VersionUnit("0", "."));
            var dt  = DisplayType.Short;

            Assert.Equal("1.0", sut.GetVersionString(dt)); //, "The short display type should have two digits");
        }
        public void PartiallyFixed_DoesIncrement()
        {
            var sut = new CompleteVersion(new VersionUnit("1", "", DigitIncremementBehaviour.ContinualIncrement), new VersionUnit("Monkey", "."));

            sut.Increment();
            Assert.Equal("2.Monkey", sut.GetVersionString(DisplayType.Full)); //, "The increment for the first digit did not work in a mixed verison number");
        }
        public void GetVersionString_Short_ShowsCorrect()
        {
            var sut = new CompleteVersion(new VersionUnit("1"), new VersionUnit("0", "."));
            var dt  = DisplayType.Short;

            Assert.Equal("1.0", sut.GetVersionString(dt));
        }
        public void GetVersionString_Short_EvenWhenMoreDigits()
        {
            var sut = new CompleteVersion(new VersionUnit("1"), new VersionUnit("0", "."), new VersionUnit("1", "."));
            var dt  = DisplayType.Short;

            Assert.Equal("1.0", sut.GetVersionString(dt));
        }
示例#10
0
        public void Display_Assem2_AllDigits_Correct()
        {
            var sut           = new CompleteVersion(new VersionUnit("2"), new VersionUnit("0", "."), new VersionUnit("0", "."), new VersionUnit("0", ".", VersionIncrementBehaviour.ContinualIncrement));
            var fut2          = sut.GetDisplayType(FileUpdateType.Assembly2);
            var verStringFor2 = sut.GetVersionString(fut2);

            Assert.Equal("2.0", verStringFor2);

            sut.PerformIncrement();
            verStringFor2 = sut.GetVersionString(fut2);

            Assert.Equal("2.0", verStringFor2);

            sut.PerformIncrement();
            verStringFor2 = sut.GetVersionString(fut2);

            Assert.Equal("2.0", verStringFor2);
        }
        public void DisplayTypes_WorkCorrectly(string version, string expectedDisplay, DisplayType dtype)
        {
            b.Info.Flow();

            CompleteVersion cv     = new CompleteVersion(version);
            string          output = cv.GetVersionString(dtype);

            Assert.Equal(expectedDisplay, output);
        }
        public void Increment_ResentAnyWorks()
        {
            var vu2 = new VersionUnit("0", ".");
            var sut = new CompleteVersion(
                new VersionUnit("1", ""),
                vu2,
                new VersionUnit("1", "."),
                new VersionUnit("0", ".", DigitIncremementBehaviour.AutoIncrementWithResetAny));

            Assert.Equal("1.0.1.0", sut.GetVersionString()); //, "Without an increment its wrong - invalid test");

            sut.Increment();
            Assert.Equal("1.0.1.1", sut.GetVersionString()); //, "Increment on all fixed should not change anything");
            vu2.IncrementOverride = "5";
            sut.Increment();

            Assert.Equal("1.5.1.0", sut.GetVersionString()); //, "The final digit should reset when a fixed digit changes.");
        }
        public void Increment_OverrideReplacesIncrement()
        {
            var vu = new VersionUnit("1", "", DigitIncremementBehaviour.ContinualIncrement);

            vu.IncrementOverride = "9";
            var sut = new CompleteVersion(vu);

            sut.Increment();
            Assert.Equal("9", sut.GetVersionString(DisplayType.Full)); //, "The overide on a word value did not work");
        }
示例#14
0
        public void Increment_OverrideReplacesIncrement()
        {
            var vu = new VersionUnit("1", "", VersionIncrementBehaviour.ContinualIncrement);

            vu.IncrementOverride = "9";
            var sut = new CompleteVersion(vu);

            sut.PerformIncrement();
            Assert.Equal("9", sut.GetVersionString(DisplayType.Full));
        }
        public void Override_NoIncrement_DoesNotChangeValue()
        {
            var vu = new VersionUnit("1");

            vu.Value             = "Monkey";
            vu.IncrementOverride = "Fish";
            var sut = new CompleteVersion(vu);

            Assert.Equal("Monkey", sut.GetVersionString(DisplayType.Full));
        }
示例#16
0
        public void UseCase_Plisky_Works()
        {
            var sut = new CompleteVersion(
                new VersionUnit("2"),
                new VersionUnit("0", "."),
                new VersionUnit("Unicorn", "-"),
                new VersionUnit("0", ".", VersionIncrementBehaviour.ContinualIncrement));

            var verString = sut.GetVersionString(DisplayType.FullIncludeText);

            Assert.Equal("2.0-Unicorn.0", verString);

            sut.PerformIncrement();
            verString = sut.GetVersionString(DisplayType.FullIncludeText);
            Assert.Equal("2.0-Unicorn.1", verString);

            sut.PerformIncrement();
            verString = sut.GetVersionString(DisplayType.FullIncludeText);
            Assert.Equal("2.0-Unicorn.2", verString);
        }
        public void Increment_ResetAnyWorks()
        {
            var sut = new CompleteVersion(
                new VersionUnit("1", "", DigitIncremementBehaviour.ContinualIncrement),
                new VersionUnit("0", "."),
                new VersionUnit("1", "."),
                new VersionUnit("0", ".", DigitIncremementBehaviour.AutoIncrementWithResetAny));

            sut.Increment();
            Assert.Equal("2.0.1.0", sut.GetVersionString(DisplayType.Full)); //, "The reset should prevent the last digit from incrementing");
        }
        public void Increment_OverrideWorksOnFixed()
        {
            var vu = new VersionUnit("1", "", DigitIncremementBehaviour.Fixed);

            vu.IncrementOverride = "Fish";

            var sut = new CompleteVersion(vu);

            sut.Increment();

            Assert.Equal("Fish", sut.GetVersionString(DisplayType.Full));
        }
        public void Increment_OverrideWorksForNames()
        {
            var vu = new VersionUnit("Monkey");

            vu.IncrementOverride = "Fish";

            var sut = new CompleteVersion(vu);

            sut.Increment();

            Assert.Equal("Fish", sut.GetVersionString(DisplayType.Full)); //, "The overide on a word value did not work");
        }
        public void Increment_OverrideWorksForNumbers()
        {
            var vu = new VersionUnit("1");

            vu.IncrementOverride = "5";

            var sut = new CompleteVersion(vu);

            sut.Increment();

            Assert.Equal("5", sut.GetVersionString(DisplayType.Full));
        }
示例#21
0
        public void VersionStoreAndLoad_StoresUpdatedValues()
        {
            string fn  = uth.NewTemporaryFileName(true);
            var    sut = new JsonVersionPersister(fn);
            var    cv  = new CompleteVersion(new VersionUnit("1", "", DigitIncremementBehaviour.ContinualIncrement),
                                             new VersionUnit("1", ".", DigitIncremementBehaviour.ContinualIncrement),
                                             new VersionUnit("1", ".", DigitIncremementBehaviour.ContinualIncrement),
                                             new VersionUnit("1", ".", DigitIncremementBehaviour.ContinualIncrement));

            cv.Increment();
            var beforeStore = cv.GetVersionString();

            sut.Persist(cv);
            var cv2 = sut.GetVersion();

            Assert.Equal(cv.GetVersionString(), cv2.GetVersionString()); //, "The two version strings should match");
            Assert.Equal("2.2.2.2", cv2.GetVersionString());             //, "The loaded version string should keep the increment");

            cv.Increment(); cv2.Increment();
            Assert.Equal(cv.GetVersionString(), cv2.GetVersionString()); //, "The two version strings should match");
        }
示例#22
0
        public void Increment_OverrideWorksOnFixed()
        {
            var vu = new VersionUnit("1", "", VersionIncrementBehaviour.Fixed);

            vu.IncrementOverride = "Fish";

            var sut = new CompleteVersion(vu);

            sut.PerformIncrement();

            Assert.Equal("Fish", sut.GetVersionString(DisplayType.Full)); //, "The overide on a word value did not work");
        }
示例#23
0
        public void Display_Assem4_AllDigitsMultiIncrement_Correct()
        {
            var sut = new CompleteVersion(new VersionUnit("2", "", VersionIncrementBehaviour.ContinualIncrement),
                                          new VersionUnit("0", ".", VersionIncrementBehaviour.ContinualIncrement),
                                          new VersionUnit("0", ".", VersionIncrementBehaviour.ContinualIncrement),
                                          new VersionUnit("0", ".", VersionIncrementBehaviour.ContinualIncrement)
                                          );

            var fut4          = sut.GetDisplayType(FileUpdateType.Assembly4);
            var verStringFor4 = sut.GetVersionString(fut4);

            Assert.Equal("2.0.0.0", verStringFor4);

            sut.PerformIncrement();
            verStringFor4 = sut.GetVersionString(fut4);

            Assert.Equal("3.1.1.1", verStringFor4);

            sut.PerformIncrement();
            verStringFor4 = sut.GetVersionString(fut4);

            Assert.Equal("4.2.2.2", verStringFor4);
        }
示例#24
0
        public void Display_Assem4_TextComponent_Correct()
        {
            var sut = new CompleteVersion(new VersionUnit("2"),
                                          new VersionUnit("0", "."),
                                          new VersionUnit("Unicorn", "-"),
                                          new VersionUnit("0", ".", VersionIncrementBehaviour.ContinualIncrement)
                                          );

            var fut4          = sut.GetDisplayType(FileUpdateType.Assembly4);
            var verStringFor4 = sut.GetVersionString(fut4);

            Assert.Equal("2.0.0.0", verStringFor4);

            sut.PerformIncrement();
            verStringFor4 = sut.GetVersionString(fut4);

            Assert.Equal("2.0.0.1", verStringFor4);

            sut.PerformIncrement();
            verStringFor4 = sut.GetVersionString(fut4);

            Assert.Equal("2.0.0.2", verStringFor4);
        }
示例#25
0
        public void UseCase_PliskyFileTypes_Works()
        {
            var sut     = new CompleteVersion(new VersionUnit("2"), new VersionUnit("0", "."), new VersionUnit("Unicorn", "-"), new VersionUnit("0", ".", VersionIncrementBehaviour.ContinualIncrement));
            var fut4    = sut.GetDisplayType(FileUpdateType.Assembly4);
            var fut2    = sut.GetDisplayType(FileUpdateType.Assembly2);
            var futInfo = sut.GetDisplayType(FileUpdateType.AssemblyInformational);

            var verStringFor4    = sut.GetVersionString(fut4);
            var verStringFor2    = sut.GetVersionString(fut2);
            var verStringForInfo = sut.GetVersionString(futInfo);

            // Initial values not incremented
            Assert.Equal("2.0.0.0", verStringFor4);
            Assert.Equal("2.0", verStringFor2);
            Assert.Equal("2.0-Unicorn.0", verStringForInfo);

            sut.PerformIncrement();
            verStringFor4    = sut.GetVersionString(fut4);
            verStringFor2    = sut.GetVersionString(fut2);
            verStringForInfo = sut.GetVersionString(futInfo);

            // Values Following Single Increment
            Assert.Equal("2.0.0.1", verStringFor4);
            Assert.Equal("2.0", verStringFor2);
            Assert.Equal("2.0-Unicorn.1", verStringForInfo);

            sut.PerformIncrement();
            verStringFor4    = sut.GetVersionString(fut4);
            verStringFor2    = sut.GetVersionString(fut2);
            verStringForInfo = sut.GetVersionString(futInfo);

            // Values Following Second Increment
            Assert.Equal("2.0.0.2", verStringFor4);
            Assert.Equal("2.0", verStringFor2);
            Assert.Equal("2.0-Unicorn.2", verStringForInfo);
        }
        public void ToString_Equals_GetVersionString()
        {
            var sut = new CompleteVersion(new VersionUnit("1"), new VersionUnit("0", "."));

            Assert.Equal(sut.ToString(), sut.GetVersionString(DisplayType.Full));
        }
示例#27
0
 protected override void ActualPersist(CompleteVersion cv)
 {
     PersistWasCalled       = true;
     VersionStringPersisted = cv.GetVersionString();
 }
示例#28
0
        public void ToString_Equals_GetVersionString()
        {
            var sut = new CompleteVersion(new VersionUnit("1"), new VersionUnit("0", "."));

            Assert.Equal(sut.ToString(), sut.GetVersionString(DisplayType.Full));//, "GetVersionString and ToString should return the same value");
        }