Ejemplo n.º 1
0
        public void UsesWhenFromNextBestMatchIfHighestDoesntHaveWhenReversedOrder()
        {
            var context = new GitVersionContextBuilder().Build();
            var when    = DateTimeOffset.Now;
            var sut     = new BaseVersionCalculator(log, new V1Strategy(null), new V2Strategy(when));

            var baseVersion = sut.GetBaseVersion(context);

            baseVersion.SemanticVersion.ToString().ShouldBe("2.0.0");
            baseVersion.ShouldIncrement.ShouldBe(true);
            baseVersion.BaseVersionSource.When().ShouldBe(when);
        }
Ejemplo n.º 2
0
        public void ChoosesHighestVersionReturnedFromStrategies()
        {
            var context        = new GitVersionContextBuilder().Build();
            var dateTimeOffset = DateTimeOffset.Now;
            var sut            = new BaseVersionCalculator(log, new V1Strategy(DateTimeOffset.Now), new V2Strategy(dateTimeOffset));

            var baseVersion = sut.GetBaseVersion(context);

            baseVersion.SemanticVersion.ToString().ShouldBe("2.0.0");
            baseVersion.ShouldIncrement.ShouldBe(true);
            baseVersion.BaseVersionSource.When().ShouldBe(dateTimeOffset);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }