Beispiel #1
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);
        }
        public void VersionStoreAndLoad_StoresDisplayTypes()
        {
            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));

            // None of the defaults are no display, therefore this should set all to a new value
            cv.SetDisplayTypeForVersion(FileUpdateType.NetAssembly, DisplayType.NoDisplay);
            cv.SetDisplayTypeForVersion(FileUpdateType.NetFile, DisplayType.NoDisplay);
            cv.SetDisplayTypeForVersion(FileUpdateType.NetInformational, DisplayType.NoDisplay);
            cv.SetDisplayTypeForVersion(FileUpdateType.Wix, DisplayType.NoDisplay);
            cv.SetDisplayTypeForVersion(FileUpdateType.StdAssembly, DisplayType.NoDisplay);
            cv.SetDisplayTypeForVersion(FileUpdateType.StdFile, DisplayType.NoDisplay);
            cv.SetDisplayTypeForVersion(FileUpdateType.StdInformational, DisplayType.NoDisplay);
            cv.SetDisplayTypeForVersion(FileUpdateType.Nuspec, DisplayType.NoDisplay);

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

            // Check that all of the display types come back as epxected
            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.NetAssembly));
            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.NetFile));
            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.NetInformational));
            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.Wix));
            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.StdAssembly));
            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.StdFile));
            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.StdInformational));
            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.Nuspec));
        }
Beispiel #3
0
        public void ManualExportVersionFile()
        {
            CompleteVersion cv = new CompleteVersion(new VersionUnit("1"), new VersionUnit("0", "."), new VersionUnit("Unicorn", "-"), new VersionUnit("0", ".", VersionIncrementBehaviour.AutoIncrementWithResetAny));
            VersionStorage  vs = new JsonVersionPersister(@"c:\temp\output.json");

            vs.Persist(cv);
        }
Beispiel #4
0
        private static void ApplyVersionIncrement()
        {
            Console.WriteLine("Apply Version Increment");
            var        per = new JsonVersionPersister(Program.options.VersionPersistanceValue);
            Versioning ver = new Versioning(per, options.TestMode);

            versionerUsed = ver.Version;

            ver.Logger = (v) => {
                Console.WriteLine(v);
            };

            if (options.PerformIncrement)
            {
                Console.WriteLine("Version Increment Requested - Currently " + ver.GetVersion());
                ver.Increment(options.Release);
            }

            Console.WriteLine("Version To Write: " + ver.GetVersion());

            // Increment done, now persist and then update the pages - first check if the command line ovverrides the minimatchers
            if ((options.VersionTargetMinMatch != null) && (options.VersionTargetMinMatch.Length > 0))
            {
                ver.LoadMiniMatches(options.VersionTargetMinMatch);
            }

            ver.SearchForAllFiles(options.Root);

            ver.UpdateAllRegisteredFiles();

            ver.SaveUpdatedVersion();
        }
        private string CreateStoredVersionNumer()
        {
            var                  fn  = uth.NewTemporaryFileName(true);
            CompleteVersion      cv  = GetDefaultVersion();
            JsonVersionPersister jvp = new JsonVersionPersister(fn);

            jvp.Persist(cv);
            return(fn);
        }
        public void VersionStorage_Json_Saves()
        {
            string fn  = uth.NewTemporaryFileName(true);
            var    sut = new JsonVersionPersister(fn);
            var    cv  = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1"), new VersionUnit("1"), new VersionUnit("1"));

            sut.Persist(cv);
            Assert.True(File.Exists(fn), "The file must be created");
        }
Beispiel #7
0
        public void Versioning_StartsAtZero()
        {
            b.Info.Flow();

            string fn = uth.NewTemporaryFileName(true);
            JsonVersionPersister jvp = new JsonVersionPersister(fn);
            var str = new Versioning(jvp).ToString();

            Assert.Equal("0.0.0.0", str);
        }
        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");
        }
Beispiel #9
0
        public void Versioning_DefaultBehaviour_IsIncrementBuild()
        {
            b.Info.Flow();

            JsonVersionPersister jvp = new JsonVersionPersister(uth.NewTemporaryFileName(true));
            Versioning           ver = new Versioning(jvp);

            string before = ver.ToString();

            ver.Increment();
            string after = ver.ToString();

            Assert.Equal("0.0.0.0", before);
            Assert.Equal("0.0.1.0", after);
        }
Beispiel #10
0
        private static void LoadVersionStore()
        {
            var        per = new JsonVersionPersister(Program.options.VersionPersistanceValue);
            Versioning ver = new Versioning(per);

            versionerUsed = ver.Version;

            if (options.PerformIncrement)
            {
                Console.WriteLine("Version Increment Requested - Currently " + ver.GetVersion());
                ver.Increment(options.Release);

                ver.SaveUpdatedVersion();
            }


            Console.WriteLine($"Loaded [{ver.GetVersion()}]");
        }
        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 UseCase_BuildVersionger_Exploratory()
        {
            string         tfn1      = uth.NewTemporaryFileName(false);
            string         tfn2      = CreateStoredVersionNumer();
            VersioningTask sut       = new VersioningTask();
            string         directory = Path.GetDirectoryName(tfn1);

            sut.BaseSearchDir    = directory;
            sut.PersistanceValue = tfn2;
            sut.AddUpdateType(tfn1, FileUpdateType.NetAssembly);
            sut.AddUpdateType(tfn1, FileUpdateType.NetFile);
            sut.AddUpdateType(tfn1, FileUpdateType.NetInformational);
            sut.IncrementAndUpdateAll();

            Assert.Equal("1.1.1.1", sut.VersionString); //, "The version string should be set post update");
            var jp = new JsonVersionPersister(tfn2);

            Assert.Equal(sut.VersionString, jp.GetVersion().GetVersionString()); //, "The update should be persisted");
            Assert.True(ts.DoesFileContainThisText(tfn1, "AssemblyVersion(\"1.1"), "The target filename was not updated");
            Assert.True(ts.DoesFileContainThisText(tfn1, "AssemblyInformationalVersion(\"1.1.1.1"), "The target filename was not updated");
            Assert.True(ts.DoesFileContainThisText(tfn1, "AssemblyFileVersion(\"1.1.1.1"), "The target filename was not updated");
        }
Beispiel #13
0
        public void VersionStoreAndLoad_StoresDisplayTypes()
        {
            string fn  = uth.NewTemporaryFileName(true);
            var    sut = new JsonVersionPersister(fn);
            var    cv  = new CompleteVersion(new VersionUnit("1", "", VersionIncrementBehaviour.ContinualIncrement),
                                             new VersionUnit("1", ".", VersionIncrementBehaviour.ContinualIncrement),
                                             new VersionUnit("1", ".", VersionIncrementBehaviour.ContinualIncrement),
                                             new VersionUnit("1", ".", VersionIncrementBehaviour.ContinualIncrement));

            // None of the defaults are no display, therefore this should set all to a new value
            cv.SetDisplayTypeForVersion(FileUpdateType.Assembly4, DisplayType.NoDisplay);
            cv.SetDisplayTypeForVersion(FileUpdateType.AssemblyFile, DisplayType.NoDisplay);
            cv.SetDisplayTypeForVersion(FileUpdateType.AssemblyInformational, DisplayType.NoDisplay);
            cv.SetDisplayTypeForVersion(FileUpdateType.Wix, DisplayType.NoDisplay);

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

            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.Assembly4));             //, "The file update type assembly was not returned correctly");
            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.AssemblyFile));          //, "The file update type AssemblyFile was not returned correctly");
            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.AssemblyInformational)); //, "The file update type AssemblyInformational was not returned correctly");
            Assert.Equal(DisplayType.NoDisplay, cv2.GetDisplayType(FileUpdateType.Wix));                   //, "The file update type assembly was not returned correctly");
        }
Beispiel #14
0
        private static void CreateNewPendingIncrement()
        {
            var        per = new JsonVersionPersister(Program.options.VersionPersistanceValue);
            Versioning ver = new Versioning(per);

            versionerUsed = ver.Version;

            string verPendPattern = options.QuickValue;

            Console.WriteLine($"Apply Delayed Incremenet. [{ver.ToString()}] using [{verPendPattern}]");
            ver.Version.ApplyPendingVersion(verPendPattern);

            if (!options.TestMode)
            {
                per.Persist(ver.Version);
                ver.Increment();
                Console.WriteLine($"Saving Overriden Version [{ver.GetVersion()}]");
            }
            else
            {
                ver.Version.Increment();
                Console.WriteLine($"Would Save " + ver.Version.ToString());
            }
        }