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");
        }
        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 SimpleIncrement_Fixed_DoesNothing()
        {
            var sut = new CompleteVersion(new VersionUnit("1"), new VersionUnit("2", "."));

            sut.Increment();
            Assert.Equal("1.2", sut.ToString()); //, "The verison increment should do nothing for fixed");
        }
        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 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");
        }
        public void SimpleIncrement_Incrment_Works()
        {
            var vu = new VersionUnit("2", ".");

            vu.SetBehaviour(DigitIncremementBehaviour.AutoIncrementWithReset);
            var sut = new CompleteVersion(new VersionUnit("1"), vu);

            sut.Increment();
            Assert.Equal("1.3", sut.ToString()); //, "The verison increment should do nothing for fixed");
        }
        public void PendingIncrementPatterns_Work(string startVer, string pattern, string endVer)
        {
            b.Info.Flow();

            CompleteVersion cv = new CompleteVersion(startVer);

            cv.ApplyPendingVersion(pattern);
            cv.Increment();

            Assert.Equal(endVer, cv.ToString());
        }
        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_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_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 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");
        }
        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));
        }
        public void PendingIncrements_StackCorrectly(string startVer, string pattern, string secondPattern, string endVer)
        {
            b.Info.Flow();
            // Multi patterns dont really stack, just partially replace

            CompleteVersion cv = new CompleteVersion(startVer);

            cv.ApplyPendingVersion(pattern);
            cv.ApplyPendingVersion(secondPattern);
            cv.Increment();

            Assert.Equal(endVer, cv.ToString());
        }
        public void PendingIncrement_IsRemovedCorrectly(string startVer, string pattern)
        {
            b.Info.Flow();

            CompleteVersion cv = new CompleteVersion(startVer);

            cv.ApplyPendingVersion(pattern);
            cv.Increment();

            Assert.Equal(null, cv.Digits[0].IncrementOverride);
            Assert.Equal(null, cv.Digits[1].IncrementOverride);
            Assert.Equal(null, cv.Digits[2].IncrementOverride);
            Assert.Equal(null, cv.Digits[3].IncrementOverride);
        }
        public void Increment_DoesNotChangeReleaseName()
        {
            const string RELEASENAME = "Unicorn";

            b.Info.Flow();

            var sut = new CompleteVersion(new VersionUnit("2"), new VersionUnit("0", "."), new VersionUnit("", "+", DigitIncremementBehaviour.ReleaseName));

            sut.ReleaseName = RELEASENAME;
            sut.Increment();

            Assert.Equal(RELEASENAME, sut.ReleaseName);
            Assert.Equal("2.0+" + RELEASENAME, sut.ToString());
        }
        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 PendingReleaseName_AppliedOnIncrement()
        {
            const string RELEASENAME = "Unicorn";
            const string NEWRELEASE  = "Phoenix";

            b.Info.Flow();

            var sut = new CompleteVersion(new VersionUnit("2"), new VersionUnit("0", "."), new VersionUnit("", "+", DigitIncremementBehaviour.ReleaseName));

            sut.ReleaseName = RELEASENAME;
            sut.ApplyPendingRelease(NEWRELEASE);

            sut.Increment();

            Assert.Equal(NEWRELEASE, sut.ReleaseName);
            Assert.Equal("2.0+" + NEWRELEASE, sut.ToString());
        }