Exemplo n.º 1
0
        public void ShouldFilterVersion()
        {
            var fakeIgnoreConfig = new TestIgnoreConfig(new ExcludeSourcesContainingExclude());
            var context          = new GitVersionContextBuilder().WithConfig(new Config
            {
                Ignore = fakeIgnoreConfig
            }).Build();
            var higherVersion = new BaseVersion(context, "exclude", false, new SemanticVersion(2), new MockCommit(), null);
            var lowerVersion  = new BaseVersion(context, "dummy", false, new SemanticVersion(1), new MockCommit(), null);

            var sp = ConfigureServices(services =>
            {
                services.RemoveAll <IVersionStrategy>();
                services.AddSingleton <IVersionStrategy>(new TestVersionStrategy(higherVersion, lowerVersion));
            });

            var versionCalculator = sp.GetService <IBaseVersionCalculator>();

            var baseVersion = versionCalculator.GetBaseVersion(context);

            baseVersion.Source.ShouldNotBe(higherVersion.Source);
            baseVersion.SemanticVersion.ShouldNotBe(higherVersion.SemanticVersion);
            baseVersion.Source.ShouldBe(lowerVersion.Source);
            baseVersion.SemanticVersion.ShouldBe(lowerVersion.SemanticVersion);
        }
Exemplo n.º 2
0
        public void ShouldFilterVersion()
        {
            var fakeIgnoreConfig = new TestIgnoreConfig(new ExcludeSourcesContainingExclude());

            var higherVersion = new BaseVersion("exclude", false, new SemanticVersion(2), GitToolsTestingExtensions.CreateMockCommit(), null);
            var lowerVersion  = new BaseVersion("dummy", false, new SemanticVersion(1), GitToolsTestingExtensions.CreateMockCommit(), null);

            var versionCalculator = GetBaseVersionCalculator(contextBuilder =>
            {
                contextBuilder
                .WithConfig(new Config {
                    Ignore = fakeIgnoreConfig
                })
                .OverrideServices(services =>
                {
                    services.RemoveAll <IVersionStrategy>();
                    services.AddSingleton <IVersionStrategy>(new TestVersionStrategy(higherVersion, lowerVersion));
                });
            });
            var baseVersion = versionCalculator.GetBaseVersion();

            baseVersion.Source.ShouldNotBe(higherVersion.Source);
            baseVersion.SemanticVersion.ShouldNotBe(higherVersion.SemanticVersion);
            baseVersion.Source.ShouldBe(lowerVersion.Source);
            baseVersion.SemanticVersion.ShouldBe(lowerVersion.SemanticVersion);
        }
Exemplo n.º 3
0
        public void ShouldNotFilterVersion()
        {
            var fakeIgnoreConfig = new TestIgnoreConfig(new ExcludeSourcesContainingExclude());
            var context          = new GitVersionContextBuilder().WithConfig(new Config()
            {
                Ignore = fakeIgnoreConfig
            }).Build();
            var version = new BaseVersion(context, "dummy", false, new SemanticVersion(2), new MockCommit(), null);
            var sut     = new BaseVersionCalculator(log, new TestVersionStrategy(version));

            var baseVersion = sut.GetBaseVersion(context);

            baseVersion.Source.ShouldBe(version.Source);
            baseVersion.ShouldIncrement.ShouldBe(version.ShouldIncrement);
            baseVersion.SemanticVersion.ShouldBe(version.SemanticVersion);
        }
Exemplo n.º 4
0
        public void ShouldFilterVersion()
        {
            var fakeIgnoreConfig = new TestIgnoreConfig(new ExcludeSourcesContainingExclude());
            var context          = new GitVersionContextBuilder().WithConfig(new Config()
            {
                Ignore = fakeIgnoreConfig
            }).Build();
            var higherVersion = new BaseVersion(context, "exclude", false, new SemanticVersion(2), new MockCommit(), null);
            var lowerVersion  = new BaseVersion(context, "dummy", false, new SemanticVersion(1), new MockCommit(), null);

            var versionStrategies = new IVersionStrategy[] { new TestVersionStrategy(higherVersion, lowerVersion) };
            var sut = new BaseVersionCalculator(log, versionStrategies);

            var baseVersion = sut.GetBaseVersion(context);

            baseVersion.Source.ShouldNotBe(higherVersion.Source);
            baseVersion.SemanticVersion.ShouldNotBe(higherVersion.SemanticVersion);
            baseVersion.Source.ShouldBe(lowerVersion.Source);
            baseVersion.SemanticVersion.ShouldBe(lowerVersion.SemanticVersion);
        }
Exemplo n.º 5
0
        public void ShouldIgnorePreReleaseVersionInMainlineMode()
        {
            var fakeIgnoreConfig = new TestIgnoreConfig(new ExcludeSourcesContainingExclude());

            var lowerVersion      = new BaseVersion("dummy", false, new SemanticVersion(1), new MockCommit(), null);
            var preReleaseVersion = new BaseVersion(
                "prerelease",
                false,
                new SemanticVersion(1, 0, 1)
            {
                PreReleaseTag = new SemanticVersionPreReleaseTag
                {
                    Name   = "alpha",
                    Number = 1
                }
            },
                new MockCommit(),
                null
                );

            var versionCalculator = GetBaseVersionCalculator(contextBuilder =>
            {
                contextBuilder
                .WithConfig(new Config {
                    VersioningMode = VersioningMode.Mainline, Ignore = fakeIgnoreConfig
                })
                .OverrideServices(services =>
                {
                    services.RemoveAll <IVersionStrategy>();
                    services.AddSingleton <IVersionStrategy>(new TestVersionStrategy(preReleaseVersion, lowerVersion));
                });
            });
            var baseVersion = versionCalculator.GetBaseVersion();

            baseVersion.Source.ShouldNotBe(preReleaseVersion.Source);
            baseVersion.SemanticVersion.ShouldNotBe(preReleaseVersion.SemanticVersion);
            baseVersion.Source.ShouldBe(lowerVersion.Source);
            baseVersion.SemanticVersion.ShouldBe(lowerVersion.SemanticVersion);
        }
Exemplo n.º 6
0
        public void ShouldNotFilterVersion()
        {
            var fakeIgnoreConfig = new TestIgnoreConfig(new ExcludeSourcesContainingExclude());
            var version          = new BaseVersion("dummy", false, new SemanticVersion(2), new MockCommit(), null);

            var versionCalculator = GetBaseVersionCalculator(contextBuilder =>
            {
                contextBuilder
                .WithConfig(new Config {
                    Ignore = fakeIgnoreConfig
                })
                .OverrideServices(services =>
                {
                    services.RemoveAll <IVersionStrategy>();
                    services.AddSingleton <IVersionStrategy>(new TestVersionStrategy(version));
                });
            });

            var baseVersion = versionCalculator.GetBaseVersion();

            baseVersion.Source.ShouldBe(version.Source);
            baseVersion.ShouldIncrement.ShouldBe(version.ShouldIncrement);
            baseVersion.SemanticVersion.ShouldBe(version.SemanticVersion);
        }
        public void ShouldNotFilterVersion()
        {
            var fakeIgnoreConfig = new TestIgnoreConfig(new ExcludeSourcesContainingExclude());
            var context = new GitVersionContextBuilder().WithConfig(new Config() { Ignore = fakeIgnoreConfig }).Build();
            var version = new BaseVersion("dummy", false, new SemanticVersion(2), new MockCommit(), null);
            var sut = new BaseVersionCalculator(new TestVersionStrategy(version));

            var baseVersion = sut.GetBaseVersion(context);

            baseVersion.Source.ShouldBe(version.Source);
            baseVersion.ShouldIncrement.ShouldBe(version.ShouldIncrement);
            baseVersion.SemanticVersion.ShouldBe(version.SemanticVersion);
        }