コード例 #1
0
        public void Bug464_BuildVersionsNotUpdatedDuringBuild()
        {
            string             srcFile = @"D:\Files\Code\git\PliskyBuild\PliskyBuildTasks\_Dependencies\TestData\BugData\B464_AsmInfo_Source.txt";
            string             fn      = ts.GetFileAsTemporary(srcFile);
            var                cv      = new CompleteVersion(new VersionUnit("2"), new VersionUnit("0", "."), new VersionUnit("Unicorn", "-"), new VersionUnit("0", ".", VersionIncrementBehaviour.ContinualIncrement));
            VersionFileUpdater sut     = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.Assembly2);
            sut.PerformUpdate(fn, FileUpdateType.AssemblyInformational);
            sut.PerformUpdate(fn, FileUpdateType.AssemblyFile);

            Assert.False(ts.DoesFileContainThisText(fn, "AssemblyFileVersion(\"2.0.0\""), "The file version should be three digits and present");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyInformationalVersion(\"2.0-Unicorn.0\""), "The informational version should be present");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyVersion(\"2.0\")"), "the assembly version should be two digits and present.");
        }
コード例 #2
0
        public void Bug464_BuildVersionsNotUpdatedDuringBuild()
        {
            var ident = TestResources.GetIdentifiers(TestResourcesReferences.Bug464RefContent);

            string srcFile = uth.GetTestDataFile(ident);

            string fn = ts.GetFileAsTemporary(srcFile);
            var    cv = new CompleteVersion(new VersionUnit("2"), new VersionUnit("0", "."),
                                            new VersionUnit("Unicorn", "-"),
                                            new VersionUnit("0", ".", DigitIncremementBehaviour.ContinualIncrement));
            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.NetAssembly);
            sut.PerformUpdate(fn, FileUpdateType.NetInformational);
            sut.PerformUpdate(fn, FileUpdateType.NetFile);

            Assert.False(ts.DoesFileContainThisText(fn, "AssemblyFileVersion(\"2.0.0\""), "The file version should be three digits and present");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyInformationalVersion(\"2.0-Unicorn.0\""), "The informational version should be present");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyVersion(\"2.0\")"), "the assembly version should be two digits and present.");
        }
コード例 #3
0
        public void Update_AsmVersion_Works()
        {
            Plisky.Build.CompleteVersion cv = new Plisky.Build.CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            string srcFile = @"D:\Files\Code\git\Scratchpad\PliskyVersioning\_Dependencies\TestData\TestFileStructure\JustAssemblyVersion.txt";
            string fn      = ts.GetFileAsTemporary(srcFile);

            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.Assembly4);

            Assert.False(ts.DoesFileContainThisText(fn, "0.0.0.0"), "No update was made to the file at all");
            Assert.True(ts.DoesFileContainThisText(fn, "1.1"), "The file does not appear to have been updated correctly.");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyVersion(\"1.1\")"), "The file does not have the full version in it");
        }
コード例 #4
0
        public void UpdateStd_AddsStdInfoWhenMissing()
        {
            var                reid    = TestResources.GetIdentifiers(TestResourcesReferences.NetStdNone);
            string             srcFile = uth.GetTestDataFile(reid);
            CompleteVersion    cv      = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            VersionFileUpdater sut     = new VersionFileUpdater(cv);
            var                before  = ts.GetVersion(FileUpdateType.StdInformational, srcFile);

            sut.PerformUpdate(srcFile, FileUpdateType.StdInformational);

            var after = ts.GetVersion(FileUpdateType.StdInformational, srcFile);

            Assert.True(string.IsNullOrEmpty(before));
            Assert.False(string.IsNullOrEmpty(after));
        }
コード例 #5
0
        public void Update_AsmFileVer_Works()
        {
            b.Info.Flow();
            var                reid    = TestResources.GetIdentifiers(TestResourcesReferences.JustFileVer);
            string             srcFile = uth.GetTestDataFile(reid);
            CompleteVersion    cv      = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            string             fn      = ts.GetFileAsTemporary(srcFile);
            VersionFileUpdater sut     = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.NetFile);

            Assert.False(ts.DoesFileContainThisText(fn, "0.0.0.0"), "No update was made to the file at all");
            Assert.True(ts.DoesFileContainThisText(fn, "1.1"), "The file does not appear to have been updated correctly.");
            Assert.True(ts.DoesFileContainThisText(fn, "AssemblyFileVersion(\"1.1.1.1\")"), "The file does not have the full version in it");
        }
コード例 #6
0
        public void Update_StdCSProjInfo_Works()
        {
            var                reid    = TestResources.GetIdentifiers(TestResourcesReferences.NetStdAll3);
            string             srcFile = uth.GetTestDataFile(reid);
            CompleteVersion    cv      = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            VersionFileUpdater sut     = new VersionFileUpdater(cv);
            var                before  = ts.GetVersion(FileUpdateType.StdInformational, srcFile);

            Assert.NotEmpty(before);

            sut.PerformUpdate(srcFile, FileUpdateType.StdInformational);

            var after = ts.GetVersion(FileUpdateType.StdInformational, srcFile);

            Assert.NotEqual <string>(before, after);
        }
コード例 #7
0
        public void Update_DoesNotAlterOtherAttributes()
        {
            Plisky.Build.CompleteVersion cv = new Plisky.Build.CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            string srcFile = @"D:\Files\Code\git\Scratchpad\PliskyVersioning\_Dependencies\TestData\TestFileStructure\DoesNotChange\assemblyinfo.txt";
            string fn      = ts.GetFileAsTemporary(srcFile);

            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.Assembly4);

            Assert.False(ts.DoesFileContainThisText(fn, " AssemblyVersion(\"1.0.0.0\")"), "No update was made to the file at all");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: AssemblyFileVersion(\"1.0.0.0\")]"), "The file does not appear to have been updated correctly.");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: AssemblyCompany(\"\")]"), "Collatoral Damage - Another element in the file was updated - Company");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: Guid(\"557cc26f-fcb2-4d0e-a34e-447295115fc3\")]"), "Collatoral Damage - Another element in the file was updated - Guid");
            Assert.True(ts.DoesFileContainThisText(fn, "// [assembly: AssemblyVersion(\"1.0.*\")]"), "Collatoral Damage - Another element in the file was updated - Comment");
            Assert.True(ts.DoesFileContainThisText(fn, "using System.Reflection;"), "Collatoral Damage - Another element in the file was updated - Reflection First Line");
        }
コード例 #8
0
        public void LiteralReplace_Version3_IsThreeDigits()
        {
            b.Info.Flow();

            var             reid    = TestResources.GetIdentifiers(TestResourcesReferences.VersionV3Txt);
            string          srcFile = uth.GetTestDataFile(reid);
            CompleteVersion cv      = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));

            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(srcFile, FileUpdateType.TextFile, DisplayType.Release);
            string result = File.ReadAllText(srcFile);

            Assert.DoesNotContain("XXX-VERSION3-XXX", result);
            Assert.DoesNotContain("1.1.1.1", result);
            Assert.Contains("1.1.1", result);
        }
コード例 #9
0
        public void Update_DoesNotAlterOtherAttributes()
        {
            b.Info.Flow();

            var    reid    = TestResources.GetIdentifiers(TestResourcesReferences.NoChangeAssemInfo);
            string srcFile = uth.GetTestDataFile(reid);

            CompleteVersion cv = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            string          fn = ts.GetFileAsTemporary(srcFile);

            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(fn, FileUpdateType.NetAssembly);

            Assert.False(ts.DoesFileContainThisText(fn, " AssemblyVersion(\"1.0.0.0\")"), "No update was made to the file at all");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: AssemblyFileVersion(\"1.0.0.0\")]"), "The file does not appear to have been updated correctly.");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: AssemblyCompany(\"\")]"), "Collatoral Damage - Another element in the file was updated - Company");
            Assert.True(ts.DoesFileContainThisText(fn, "[assembly: Guid(\"557cc26f-fcb2-4d0e-a34e-447295115fc3\")]"), "Collatoral Damage - Another element in the file was updated - Guid");
            Assert.True(ts.DoesFileContainThisText(fn, "// [assembly: AssemblyVersion(\"1.0.*\")]"), "Collatoral Damage - Another element in the file was updated - Comment");
            Assert.True(ts.DoesFileContainThisText(fn, "using System.Reflection;"), "Collatoral Damage - Another element in the file was updated - Reflection First Line");
        }
コード例 #10
0
        public void LiteralReplace_DefaultReplacesVersionAndReleaseName()
        {
            b.Info.Flow();

            var             reid    = TestResources.GetIdentifiers(TestResourcesReferences.ReleaseNameAndVerTxt);
            string          srcFile = uth.GetTestDataFile(reid);
            CompleteVersion cv      = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));

            cv.ReleaseName = "Unicorn";

            VersionFileUpdater sut = new VersionFileUpdater(cv);

            sut.PerformUpdate(srcFile, FileUpdateType.TextFile, DisplayType.Release);


            string result = File.ReadAllText(srcFile);

            Assert.DoesNotContain("XXX-RELEASENAME-XXX", result);
            Assert.Contains("Unicorn", result);
            Assert.DoesNotContain("XXX-VERSION-XXX", result);
            Assert.Contains("1.1.1.1", result);
        }
コード例 #11
0
        public void Update_Nuspec_BugNoUpdate()
        {
            b.Info.Flow();
            // BUG Case - for some reason nuspec was not being updated.  B_NuspecUpdateFailed

            var    reid    = TestResources.GetIdentifiers(TestResourcesReferences.BugNuspecUpdateFail);
            string srcFile = uth.GetTestDataFile(reid);

            CompleteVersion    cv  = new CompleteVersion(new VersionUnit("1"), new VersionUnit("1", "."), new VersionUnit("1", "."), new VersionUnit("1", "."));
            VersionFileUpdater sut = new VersionFileUpdater(cv);

            string knownStartPoint  = "<version>1.7.2.0</version>";
            string destinationPoint = "<version>1.1.1.1</version>";
            string txt = File.ReadAllText(srcFile);

            sut.PerformUpdate(srcFile, FileUpdateType.Nuspec, DisplayType.Release);
            string txt2 = File.ReadAllText(srcFile);

            Assert.True(txt.IndexOf(knownStartPoint) > 0);
            Assert.False(txt.IndexOf(destinationPoint) > 0);
            Assert.False(txt2.IndexOf(knownStartPoint) > 0);
            Assert.True(txt2.IndexOf(destinationPoint) > 0);
        }