コード例 #1
0
    public void ShouldNotCreateAssemblyInfoFileForUnknownSourceCodeAndEnsureAssemblyInfo()
    {
        var fileSystem       = Substitute.For <IFileSystem>();
        var workingDir       = Path.GetTempPath();
        var assemblyInfoFile = "VersionAssemblyInfo.js";
        var fullPath         = Path.Combine(workingDir, assemblyInfoFile);
        var variables        = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);

        using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true))
        {
            assemblyInfoFileUpdater.Update();

            fileSystem.Received(0).WriteAllText(fullPath, Arg.Any <string>());
        }
    }
コード例 #2
0
    public void OutputsShouldMatchVariableProvider()
    {
        var taskType   = typeof(GetVersion);
        var properties = taskType.GetProperties()
                         .Where(p => p.GetCustomAttributes(typeof(OutputAttribute), false).Any())
                         .Select(p => p.Name);
        var variables = VariableProvider.GetVariablesFor(new SemanticVersion
        {
            Major         = 1,
            Minor         = 2,
            Patch         = 3,
            BuildMetaData = new SemanticVersionBuildMetaData(5, "develop", "commitSha", DateTimeOffset.Parse("2014-03-06 23:59:59Z"))
        }).Keys;

        CollectionAssert.AreEquivalent(properties, variables);
    }
コード例 #3
0
        private GitVersionCalculator GetGitVersionCalculator(Arguments arguments)
        {
            var options = Options.Create(arguments);

            var gitPreparer               = new GitPreparer(log, environment, options);
            var stepFactory               = new ConfigInitStepFactory();
            var configInitWizard          = new ConfigInitWizard(new ConsoleAdapter(), stepFactory);
            var configurationProvider     = new ConfigProvider(fileSystem, log, configFileLocator, gitPreparer, configInitWizard);
            var baseVersionCalculator     = new BaseVersionCalculator(log, null);
            var mainlineVersionCalculator = new MainlineVersionCalculator(log, metaDataCalculator);
            var nextVersionCalculator     = new NextVersionCalculator(log, metaDataCalculator, baseVersionCalculator, mainlineVersionCalculator);
            var variableProvider          = new VariableProvider(nextVersionCalculator, new TestEnvironment());
            var gitVersionCalculator      = new GitVersionCalculator(fileSystem, log, configFileLocator, configurationProvider, buildServerResolver, gitVersionCache, gitVersionFinder, gitPreparer, variableProvider, options);

            return(gitVersionCalculator);
        }
コード例 #4
0
    public VersionVariables GetVersion(IRepository repository = null, string commitId = null)
    {
        var gitVersionContext = new GitVersionContext(repository ?? Repository, configuration, IsForTrackedBranchOnly, commitId);
        var executeGitVersion = ExecuteGitVersion(gitVersionContext);
        var variables         = VariableProvider.GetVariablesFor(executeGitVersion, gitVersionContext.Configuration, gitVersionContext.IsCurrentCommitTagged);

        try
        {
            return(variables);
        }
        catch (Exception)
        {
            Console.WriteLine("Test failing, dumping repository graph");
            gitVersionContext.Repository.DumpGraph();
            throw;
        }
    }
コード例 #5
0
    public void ShouldStartSearchFromWorkingDirectory()
    {
        var fileSystem = Substitute.For <IFileSystem>();
        var workingDir = Path.GetTempPath();

        var config    = new TestEffectiveConfiguration();
        var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), config, false);
        var arguments = new Arguments
        {
            UpdateAssemblyInfo = true
        };

        using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem))
        {
            fileSystem.Received().DirectoryGetFiles(Arg.Is(workingDir), Arg.Any <string>(), Arg.Any <SearchOption>());
        }
    }
コード例 #6
0
        public static void InitializeImportantVariables()
        {
            Camera.Position       = Vector2.Zero;
            Camera.ViewPortWidth  = 800;
            Camera.ViewPortHeight = 600;


            InputMapper.ActionKeys = new Keys[] { Keys.Enter, Keys.E };
            InputMapper.JumpKeys   = new Keys[] { Keys.Space, Keys.Space };
            InputMapper.UpKeys     = new Keys[] { Keys.W, Keys.Up };
            InputMapper.DownKeys   = new Keys[] { Keys.S, Keys.Down };
            InputMapper.LeftKeys   = new Keys[] { Keys.A, Keys.Left };
            InputMapper.RightKeys  = new Keys[] { Keys.D, Keys.Right };
            InputMapper.CancelKeys = new Keys[] { Keys.Escape };

            VariableProvider.GenerateNewRandomSeed();
        }
コード例 #7
0
    public void ProvidesVariablesInContinuousDeploymentModeForStable()
    {
        var semVer = new SemanticVersion
        {
            Major         = 1,
            Minor         = 2,
            Patch         = 3,
            BuildMetaData = "5.Branch.develop"
        };

        semVer.BuildMetaData.Sha        = "commitSha";
        semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");

        var vars = VariableProvider.GetVariablesFor(semVer, AssemblyVersioningScheme.MajorMinorPatch, VersioningMode.ContinuousDeployment, "ci", false);

        Approvals.Verify(JsonOutputFormatter.ToJson(vars));
    }
コード例 #8
0
    public void ShouldNotCreateCSharpAssemblyInfoFileWhenNotExistsAndNotEnsureAssemblyInfo()
    {
        var           fileSystem       = new TestFileSystem();
        var           workingDir       = Path.GetTempPath();
        ISet <string> assemblyInfoFile = new HashSet <string> {
            "VersionAssemblyInfo.cs"
        };
        var fullPath = Path.Combine(workingDir, assemblyInfoFile.First());

        var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);

        using (new AssemblyInfoFileUpdate(new Arguments {
            UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = assemblyInfoFile
        }, workingDir, variables, fileSystem))
        {
            fileSystem.Exists(fullPath).ShouldBeFalse();
        }
    }
コード例 #9
0
    public void ShouldCreateCSharpAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo()
    {
        var           fileSystem       = new TestFileSystem();
        var           workingDir       = Path.GetTempPath();
        ISet <string> assemblyInfoFile = new HashSet <string> {
            Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo.cs")
        };
        var fullPath = Path.Combine(workingDir, assemblyInfoFile.First());

        var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);

        using (new AssemblyInfoFileUpdate(new Arguments {
            EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = assemblyInfoFile
        }, workingDir, variables, fileSystem))
        {
            fileSystem.ReadAllText(fullPath).ShouldMatchApproved();
        }
    }
コード例 #10
0
    public void ShouldNotCreateAssemblyInfoFileForUnknownSourceCodeAndEnsureAssemblyInfo()
    {
        var           fileSystem       = Substitute.For <IFileSystem>();
        var           workingDir       = Path.GetTempPath();
        ISet <string> assemblyInfoFile = new HashSet <string> {
            "VersionAssemblyInfo.js"
        };
        var fullPath = Path.Combine(workingDir, assemblyInfoFile.First());

        var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);

        using (new AssemblyInfoFileUpdate(new Arguments {
            EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = assemblyInfoFile
        }, workingDir, variables, fileSystem))
        {
            fileSystem.Received(0).WriteAllText(fullPath, Arg.Any <string>());
        }
    }
コード例 #11
0
        public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Config configuration, IRepository repository = null, string commitId = null, bool isForTrackedBranchOnly = true)
        {
            ConfigurationProvider.ApplyDefaultsTo(configuration);
            var gitVersionContext = new GitVersionContext(repository ?? fixture.Repository, configuration, isForTrackedBranchOnly, commitId);
            var executeGitVersion = ExecuteGitVersion(gitVersionContext);
            var variables         = VariableProvider.GetVariablesFor(executeGitVersion, gitVersionContext.Configuration, gitVersionContext.IsCurrentCommitTagged);

            try
            {
                return(variables);
            }
            catch (Exception)
            {
                Console.WriteLine("Test failing, dumping repository graph");
                gitVersionContext.Repository.DumpGraph();
                throw;
            }
        }
コード例 #12
0
    public void Json()
    {
        var semanticVersion = new SemanticVersion
        {
            Major         = 1,
            Minor         = 2,
            Patch         = 0,
            PreReleaseTag = "unstable4",
            BuildMetaData = new SemanticVersionBuildMetaData(5, "feature1", "commitSha", "commitShortSha", DateTimeOffset.Parse("2014-03-06 23:59:59Z"))
        };

        var config = new TestEffectiveConfiguration();

        var variables = VariableProvider.GetVariablesFor(semanticVersion, config, false);
        var json      = JsonOutputFormatter.ToJson(variables);

        json.ShouldMatchApproved(c => c.SubFolder("Approved"));
    }
コード例 #13
0
        public ExecutionResults ExecuteGitVersion(bool inProcess = true)
        {
            if (!inProcess)
            {
                return(GitVersionHelper.ExecuteIn(RepositoryPath));
            }

            var vf = new GitVersionFinder();
            var sv = vf.FindVersion(new GitVersionContext
            {
                Repository    = Repository,
                CurrentBranch = Repository.Head
            });

            var vars = VariableProvider.GetVariablesFor(sv);

            return(new InProcessExecutionResults(vars));
        }
コード例 #14
0
        public void FindsVersionInDynamicRepo(string name, string url, string targetBranch, string commitId, string expectedFullSemVer)
        {
            var root             = Path.Combine(workDirectory, name);
            var dynamicDirectory = Path.Combine(root, "D"); // dynamic, keeping directory as short as possible
            var workingDirectory = Path.Combine(root, "W"); // working, keeping directory as short as possible
            var arguments        = new Arguments
            {
                TargetUrl = url,
                DynamicRepositoryLocation = dynamicDirectory,
                TargetBranch = targetBranch,
                NoFetch      = false,
                TargetPath   = workingDirectory,
                CommitId     = commitId
            };
            var options = Options.Create(arguments);

            Directory.CreateDirectory(dynamicDirectory);
            Directory.CreateDirectory(workingDirectory);

            var testFileSystem      = new TestFileSystem();
            var log                 = new NullLog();
            var configFileLocator   = new DefaultConfigFileLocator(testFileSystem, log);
            var gitVersionCache     = new GitVersionCache(testFileSystem, log);
            var buildServerResolver = new BuildServerResolver(null, log);

            var metadataCalculator        = new MetaDataCalculator();
            var baseVersionCalculator     = new TestBaseVersionStrategiesCalculator(log);
            var mainlineVersionCalculator = new MainlineVersionCalculator(log, metadataCalculator);
            var nextVersionCalculator     = new NextVersionCalculator(log, metadataCalculator, baseVersionCalculator, mainlineVersionCalculator);
            var gitVersionFinder          = new GitVersionFinder(log, nextVersionCalculator);

            var gitPreparer      = new GitPreparer(log, new TestEnvironment(), options);
            var stepFactory      = new ConfigInitStepFactory();
            var configInitWizard = new ConfigInitWizard(new ConsoleAdapter(), stepFactory);

            var configurationProvider = new ConfigProvider(testFileSystem, log, configFileLocator, gitPreparer, configInitWizard);

            var variableProvider     = new VariableProvider(nextVersionCalculator, new TestEnvironment());
            var gitVersionCalculator = new GitVersionCalculator(testFileSystem, log, configFileLocator, configurationProvider, buildServerResolver, gitVersionCache, gitVersionFinder, gitPreparer, variableProvider, options);

            var versionVariables = gitVersionCalculator.CalculateVersionVariables();

            Assert.AreEqual(expectedFullSemVer, versionVariables.FullSemVer);
        }
コード例 #15
0
    public void ProvidesVariablesInContinuousDeploymentModeForStable()
    {
        var semVer = new SemanticVersion
        {
            Major         = 1,
            Minor         = 2,
            Patch         = 3,
            BuildMetaData = "5.Branch.develop"
        };

        semVer.BuildMetaData.Sha        = "commitSha";
        semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");

        var config = new TestEffectiveConfiguration(versioningMode: VersioningMode.ContinuousDeployment);

        var vars = VariableProvider.GetVariablesFor(semVer, config, false);

        JsonOutputFormatter.ToJson(vars).ShouldMatchApproved();
    }
コード例 #16
0
    public void ShouldCreateFSharpAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo()
    {
        var           fileSystem       = Substitute.For <IFileSystem>();
        var           workingDir       = Path.GetTempPath();
        ISet <string> assemblyInfoFile = new HashSet <string> {
            "VersionAssemblyInfo.fs"
        };
        var fullPath = Path.Combine(workingDir, assemblyInfoFile.First());

        var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);

        using (new AssemblyInfoFileUpdate(new Arguments {
            EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = assemblyInfoFile
        }, workingDir, variables, fileSystem))
        {
            var source = AssemblyVersionInfoTemplates.GetAssemblyInfoTemplateFor(fullPath);
            fileSystem.Received().WriteAllText(fullPath, source);
        }
    }
コード例 #17
0
    public void DevelopBranchFormatsSemVerForCiFeed()
    {
        var semVer = new SemanticVersion
        {
            Major         = 1,
            Minor         = 2,
            Patch         = 3,
            PreReleaseTag = "unstable.4",
            BuildMetaData = "5.Branch.develop"
        };

        semVer.BuildMetaData.Sha        = "commitSha";
        semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");


        var vars = VariableProvider.GetVariablesFor(semVer, new Config());

        vars[VariableProvider.SemVer].ShouldBe("1.2.3.5-unstable");
    }
コード例 #18
0
    public void ProvidesVariablesInContinuousDeploymentModeWithTagSetToUseBranchName()
    {
        var semVer = new SemanticVersion
        {
            Major         = 1,
            Minor         = 2,
            Patch         = 3,
            BuildMetaData = "5.Branch.develop"
        };

        semVer.BuildMetaData.Branch     = "feature";
        semVer.BuildMetaData.Sha        = "commitSha";
        semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");

        var config = new TestEffectiveConfiguration(versioningMode: VersioningMode.ContinuousDeployment, tag: "useBranchName");
        var vars   = VariableProvider.GetVariablesFor(semVer, config, false);

        vars.FullSemVer.ShouldBe("1.2.3-feature.5");
    }
コード例 #19
0
    public string GetAssemblyInfoText(Config configuration)
    {
        var semanticVersion = CachedVersion.SemanticVersion;
        var vars            = VariableProvider.GetVariablesFor(semanticVersion, configuration);
        var assemblyInfo    = string.Format(@"
using System;
using System.Reflection;

[assembly: AssemblyVersion(""{0}"")]
[assembly: AssemblyFileVersion(""{1}"")]
[assembly: AssemblyInformationalVersion(""{2}"")]
[assembly: ReleaseDate(""{3}"", ""{4}"")]

[System.Runtime.CompilerServices.CompilerGenerated]
sealed class ReleaseDateAttribute : System.Attribute
{{
    public string OriginalDate {{ get; private set; }}
    public string Date {{ get; private set; }}

    public ReleaseDateAttribute(string originalDate, string date)
    {{
        OriginalDate = originalDate;
        Date = date;
    }}
}}

[System.Runtime.CompilerServices.CompilerGenerated]
static class GitVersionInformation
{{
{5}
}}


", vars[VariableProvider.AssemblySemVer],
                                            vars[VariableProvider.AssemblyFileSemVer],
                                            semanticVersion.ToString("i"),
                                            CachedVersion.MasterReleaseDate.UtcDateTime.ToString("yyyy-MM-dd"),
                                            semanticVersion.BuildMetaData.CommitDate.UtcDateTime.ToString("yyyy-MM-dd"),
                                            GenerateVariableMembers(vars));

        return(assemblyInfo);
    }
コード例 #20
0
    public void ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged()
    {
        var semVer = new SemanticVersion
        {
            Major         = 1,
            Minor         = 2,
            Patch         = 3,
            BuildMetaData =
            {
                CommitsSinceTag =           5,
                Sha             = "commitSha",
                CommitDate      = DateTimeOffset.Parse("2014-03-06 23:59:59Z")
            }
        };


        var vars = VariableProvider.GetVariablesFor(semVer, AssemblyVersioningScheme.MajorMinorPatch, VersioningMode.ContinuousDeployment, "ci", true);

        Approvals.Verify(JsonOutputFormatter.ToJson(vars));
    }
コード例 #21
0
    public void ProvidesVariablesInContinuousDeploymentModeWithTagNamePattern()
    {
        var semVer = new SemanticVersion
        {
            Major         = 1,
            Minor         = 2,
            Patch         = 3,
            PreReleaseTag = "PullRequest",
            BuildMetaData = "5.Branch.develop"
        };

        semVer.BuildMetaData.Branch     = "pull/2/merge";
        semVer.BuildMetaData.Sha        = "commitSha";
        semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");

        var config = new TestEffectiveConfiguration(versioningMode: VersioningMode.ContinuousDeployment, tagNumberPattern: @"[/-](?<number>\d+)[-/]");
        var vars   = VariableProvider.GetVariablesFor(semVer, config, false);

        vars.FullSemVer.ShouldBe("1.2.3-PullRequest0002.5");
    }
コード例 #22
0
    public void BuildNumberIsFullSemVer()
    {
        var writes          = new List <string>();
        var semanticVersion = new SemanticVersion
        {
            Major         = 1,
            Minor         = 2,
            Patch         = 3,
            PreReleaseTag = "beta1",
            BuildMetaData = "5"
        };

        semanticVersion.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");
        semanticVersion.BuildMetaData.Sha        = "commitSha";
        var variables = VariableProvider.GetVariablesFor(semanticVersion, AssemblyVersioningScheme.MajorMinorPatch, VersioningMode.ContinuousDelivery, "ci", false);

        new BuildServer().WriteIntegration(writes.Add, variables);

        writes[1].ShouldBe("1.2.3-beta.1+5");
    }
コード例 #23
0
    public void ProvidesVariablesInContinuousDeliveryModeForPreReleaseWithPadding()
    {
        var semVer = new SemanticVersion
        {
            Major         = 1,
            Minor         = 2,
            Patch         = 3,
            PreReleaseTag = "unstable.4",
            BuildMetaData = "5.Branch.develop"
        };

        semVer.BuildMetaData.Sha        = "commitSha";
        semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");


        var config = new TestEffectiveConfiguration(buildMetaDataPadding: 2, legacySemVerPadding: 5);

        var vars = VariableProvider.GetVariablesFor(semVer, config, false);

        JsonOutputFormatter.ToJson(vars).ShouldMatchApproved();
    }
コード例 #24
0
    public void AssertFullSemver(string fullSemver, IRepository repository = null, string commitId = null)
    {
        var gitVersionContext = new GitVersionContext(repository ?? Repository, configuration, IsForTrackedBranchOnly, commitId);
        var executeGitVersion = ExecuteGitVersion(gitVersionContext);
        var variables         = VariableProvider.GetVariablesFor(executeGitVersion,
                                                                 gitVersionContext.Configuration.AssemblyVersioningScheme,
                                                                 gitVersionContext.Configuration.VersioningMode,
                                                                 gitVersionContext.Configuration.ContinuousDeploymentFallbackTag,
                                                                 gitVersionContext.IsCurrentCommitTagged);

        try
        {
            variables.FullSemVer.ShouldBe(fullSemver);
        }
        catch (Exception)
        {
            Trace.WriteLine("Test failing, dumping repository graph");
            repository.DumpGraph();
            throw;
        }
    }
コード例 #25
0
        public override bool Execute()
        {
            try
            {
                Tuple <CachedVersion, GitVersionContext> versionAndBranch;
                var gitDirectory  = GitDirFinder.TreeWalkForGitDir(SolutionDirectory);
                var configuration = ConfigurationProvider.Provide(gitDirectory, fileSystem);

                if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch, configuration))
                {
                    var thisType          = typeof(GetVersion);
                    var cachedVersion     = versionAndBranch.Item1;
                    var gitVersionContext = versionAndBranch.Item2;
                    var config            = gitVersionContext.Configuration;
                    var variables         = VariableProvider.GetVariablesFor(
                        cachedVersion.SemanticVersion, config.AssemblyVersioningScheme,
                        config.VersioningMode, config.ContinuousDeploymentFallbackTag,
                        gitVersionContext.IsCurrentCommitTagged);
                    foreach (var variable in variables)
                    {
                        thisType.GetProperty(variable.Key).SetValue(this, variable.Value, null);
                    }
                }
                return(true);
            }
            catch (WarningException errorException)
            {
                logger.LogWarning(errorException.Message);
                return(true);
            }
            catch (Exception exception)
            {
                logger.LogError("Error occurred: " + exception);
                return(false);
            }
            finally
            {
                Logger.Reset();
            }
        }
コード例 #26
0
    public string GetAssemblyInfoText(EffectiveConfiguration configuration)
    {
        var semanticVersion = CachedVersion.SemanticVersion;
        var vars            = VariableProvider.GetVariablesFor(semanticVersion, configuration.AssemblyVersioningScheme, configuration.VersioningMode, "ci", false);
        var assemblyInfo    = string.Format(@"
using System;
using System.Reflection;

[assembly: AssemblyVersion(""{0}"")]
[assembly: AssemblyFileVersion(""{1}"")]
[assembly: AssemblyInformationalVersion(""{2}"")]
[assembly: ReleaseDate(""{3}"")]

[System.Runtime.CompilerServices.CompilerGenerated]
sealed class ReleaseDateAttribute : System.Attribute
{{
    public string Date {{ get; private set; }}

    public ReleaseDateAttribute(string date)
    {{
        Date = date;
    }}
}}

[System.Runtime.CompilerServices.CompilerGenerated]
static class GitVersionInformation
{{
{4}
}}


",
                                            vars.AssemblySemVer,
                                            vars.MajorMinorPatch + ".0",
                                            semanticVersion.ToString("i"),
                                            semanticVersion.BuildMetaData.CommitDate.UtcDateTime.ToString("yyyy-MM-dd"),
                                            GenerateVariableMembers(vars));

        return(assemblyInfo);
    }
コード例 #27
0
    public void ShouldReplaceAssemblyVersionInRelativePath()
    {
        var fileSystem = Substitute.For <IFileSystem>();
        var version    = new SemanticVersion
        {
            BuildMetaData = new SemanticVersionBuildMetaData(3, "foo", "hash", DateTimeOffset.Now),
            Major         = 2,
            Minor         = 3,
            Patch         = 1
        };

        var    workingDir       = Path.GetTempPath();
        string assemblyInfoFile = Join(@"AssemblyVersion(""1.0.0.0"");",
                                       @"AssemblyInformationalVersion(""1.0.0.0"");",
                                       @"AssemblyFileVersion(""1.0.0.0"");");

        var fileName = Path.Combine(workingDir, "Project", "src", "Properties", "AssemblyInfo.cs");

        fileSystem.Exists(fileName).Returns(true);
        fileSystem.ReadAllText(fileName).Returns(assemblyInfoFile);

        var config = new TestEffectiveConfiguration(assemblyVersioningScheme: AssemblyVersioningScheme.MajorMinor);

        var variable = VariableProvider.GetVariablesFor(version, config, false);
        var args     = new Arguments
        {
            UpdateAssemblyInfo         = true,
            UpdateAssemblyInfoFileName = new HashSet <string> {
                Path.Combine("Project", "src", "Properties", "AssemblyInfo.cs")
            }
        };

        using (new AssemblyInfoFileUpdate(args, workingDir, variable, fileSystem))
        {
            string expected = Join(@"AssemblyVersion(""2.3.0.0"");",
                                   @"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"");",
                                   @"AssemblyFileVersion(""2.3.1.0"");");
            fileSystem.Received().WriteAllText(fileName, expected);
        }
    }
コード例 #28
0
    public void ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo(string fileExtension)
    {
        var fileSystem       = new TestFileSystem();
        var workingDir       = Path.GetTempPath();
        var assemblyInfoFile = new HashSet <string>
        {
            "VersionAssemblyInfo." + fileExtension
        };
        var fullPath  = Path.Combine(workingDir, assemblyInfoFile.First());
        var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
        var arguments = new Arguments
        {
            EnsureAssemblyInfo         = true,
            UpdateAssemblyInfo         = true,
            UpdateAssemblyInfoFileName = assemblyInfoFile
        };

        using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem))
        {
            fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension)));
        }
    }
コード例 #29
0
    public void ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension)
    {
        var fileSystem        = new TestFileSystem();
        var workingDir        = Path.GetTempPath();
        var assemblyInfoFiles = new HashSet <string>
        {
            "AssemblyInfo." + fileExtension,
            Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension)
        };
        var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);

        using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFiles, workingDir, variables, fileSystem, true))
        {
            assemblyInfoFileUpdater.Update();

            foreach (var item in assemblyInfoFiles)
            {
                var fullPath = Path.Combine(workingDir, item);
                fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension)));
            }
        }
    }
コード例 #30
0
    public void ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged()
    {
        var semVer = new SemanticVersion
        {
            Major         = 1,
            Minor         = 2,
            Patch         = 3,
            BuildMetaData =
            {
                CommitsSinceTag           =           5,
                CommitsSinceVersionSource =           5,
                Sha        = "commitSha",
                CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z")
            }
        };

        var config = new TestEffectiveConfiguration(versioningMode: VersioningMode.ContinuousDeployment);

        var vars = VariableProvider.GetVariablesFor(semVer, config, true);

        JsonOutputFormatter.ToJson(vars).ShouldMatchApproved();
    }
コード例 #31
0
 public VariableProviderTests()
 {
     _sut = new VariableProvider();
 }