示例#1
0
    public void DoesNotIncrementWhenBaseVersionSaysNotTo()
    {
        var semanticVersionBuildMetaData = new SemanticVersionBuildMetaData("ef7d0d7e1e700f1c7c9fa01ea6791bb778a5c37c", 1, MainBranch, "b1a34edbd80e141f7cc046c074f109be7d022074", "b1a34e", DateTimeOffset.Now, 0);

        var contextBuilder = new GitVersionContextBuilder();

        contextBuilder
        .OverrideServices(services =>
        {
            var testBaseVersionCalculator = new TestBaseVersionCalculator(false, new SemanticVersion(1), GitToolsTestingExtensions.CreateMockCommit());
            services.AddSingleton <IBaseVersionCalculator>(testBaseVersionCalculator);
            services.AddSingleton <IMainlineVersionCalculator>(new TestMainlineVersionCalculator(semanticVersionBuildMetaData));
        })
        .WithConfig(new Config())
        .Build();

        contextBuilder.ServicesProvider.ShouldNotBeNull();
        var nextVersionCalculator = contextBuilder.ServicesProvider.GetRequiredService <INextVersionCalculator>();

        nextVersionCalculator.ShouldNotBeNull();

        var version = nextVersionCalculator.FindVersion();

        version.ToString().ShouldBe("1.0.0");
    }
示例#2
0
        public void AppliesBranchPreReleaseTag()
        {
            var semanticVersionBuildMetaData = new SemanticVersionBuildMetaData("ef7d0d7e1e700f1c7c9fa01ea6791bb778a5c37c", 2, "develop", "b1a34edbd80e141f7cc046c074f109be7d022074", "b1a34e", DateTimeOffset.Now, 0);
            var contextBuilder = new GitVersionContextBuilder();

            contextBuilder
            .OverrideServices(services =>
            {
                services.AddSingleton <IBaseVersionCalculator>(new TestBaseVersionCalculator(false, new SemanticVersion(1), new MockCommit()));
                services.AddSingleton <IMainlineVersionCalculator>(new TestMainlineVersionCalculator(semanticVersionBuildMetaData));
            })
            .WithDevelopBranch()
            .Build();

            var nextVersionCalculator = contextBuilder.ServicesProvider.GetService <INextVersionCalculator>();

            nextVersionCalculator.ShouldNotBeNull();

            var version = nextVersionCalculator.FindVersion();

            version.ToString("f").ShouldBe("1.0.0-alpha.1+2");
        }
示例#3
0
        public void ShouldIncrementVersionBasedOnConfig()
        {
            var semanticVersionBuildMetaData = new SemanticVersionBuildMetaData("ef7d0d7e1e700f1c7c9fa01ea6791bb778a5c37c", 1, "master", "b1a34edbd80e141f7cc046c074f109be7d022074", "b1a34e", DateTimeOffset.Now, 0);

            var contextBuilder = new GitVersionContextBuilder();

            contextBuilder
            .OverrideServices(services =>
            {
                services.AddSingleton <IBaseVersionCalculator>(new TestBaseVersionCalculator(true, new SemanticVersion(1), new MockCommit()));
                services.AddSingleton <IMainlineVersionCalculator>(new TestMainlineVersionCalculator(semanticVersionBuildMetaData));
            })
            .WithConfig(new Config())
            .Build();

            var nextVersionCalculator = contextBuilder.ServicesProvider.GetService <INextVersionCalculator>();

            nextVersionCalculator.ShouldNotBeNull();

            var version = nextVersionCalculator.FindVersion();

            version.ToString().ShouldBe("1.0.1");
        }