Beispiel #1
0
        public static async Task DoesNotHaveBuildMetadata()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);

            await Git.Commit(path);

            await Git.Tag(path, "2.3.4+build.5");

            await Git.Commit(path);

            var expected = Package.WithVersion(2, 3, 5, new[] { "alpha", "0" }, 1);

            // act
            var(sdkActual, _) = await Sdk.BuildProject(path);

            var(cliActual, _) = await MinVerCli.Run(path);

            // assert
            Assert.Equal(expected, sdkActual);
            Assert.Equal(expected.Version, cliActual);
        }
Beispiel #2
0
        public static async Task HasCustomDefaultPreReleasePhase()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);

            await Git.Commit(path);

            await Git.Tag(path, "2.3.4");

            await Git.Commit(path);

            var envVars = ("MinVerDefaultPreReleasePhase".ToAltCase(), "preview");

            var expected = Package.WithVersion(2, 3, 5, new[] { "preview", "0" }, 1);

            // act
            var(sdkActual, _) = await Sdk.BuildProject(path, envVars : envVars);

            var(cliActual, _) = await MinVerCli.Run(path, envVars : envVars);

            // assert
            Assert.Equal(expected, sdkActual);
            Assert.Equal(expected.Version, cliActual);
        }
Beispiel #3
0
        public static async Task HasCustomAutoIncrement()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);

            await Git.Commit(path);

            await Git.Tag(path, "2.3.4");

            await Git.Commit(path);

            var envVars = ("MinVerAutoIncrement".ToAltCase(), "minor");

            var expected = Package.WithVersion(2, 4, 0, new[] { "alpha", "0" }, 1);

            // act
            var(sdkActual, _) = await Sdk.BuildProject(path, envVars : envVars);

            var(cliActual, _) = await MinVerCli.Run(path, envVars : envVars);

            // assert
            Assert.Equal(expected, sdkActual);
            Assert.Equal(expected.Version, cliActual);
        }
Beispiel #4
0
        public static async Task HasTagVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);

            await Git.Commit(path);

            await Git.Tag(path, "v.2.3.4-alpha.5");

            var envVars = ("MinVerTagPrefix", "v.");

            var expected = Package.WithVersion(2, 3, 4, new[] { "alpha", "5" });

            // act
            var(sdkActual, _) = await Sdk.BuildProject(path, envVars : envVars);

            var(cliActual, _) = await MinVerCli.Run(path, envVars : envVars);

            // assert
            Assert.Equal(expected, sdkActual);
            Assert.Equal(expected.Version, cliActual);
        }
Beispiel #5
0
        public static async Task HasVersionOverride()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);

            await Git.Commit(path);

            await Git.Tag(path, "2.3.4");

            var envVars = ("MinVerVersionOverride".ToAltCase(), "3.4.5-alpha.6+build.7");

            var expected = Package.WithVersion(3, 4, 5, new[] { "alpha", "6" }, 0, "build.7");

            // act
            var(sdkActual, _) = await Sdk.BuildProject(path, envVars : envVars);

            var(cliActual, _) = await MinVerCli.Run(path, envVars : envVars);

            // assert
            Assert.Equal(expected, sdkActual);
            Assert.Equal(expected.Version, cliActual);
        }
Beispiel #6
0
        public static async Task HasBuildMetadata()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            var envVars  = ("MinVerBuildMetadata", "build.123");
            var expected = Package.WithVersion(0, 0, 0, new[] { "alpha", "0" }, 0, "build.123");

            // act
            var(sdkActual, _) = await Sdk.BuildProject(path, envVars : envVars);

            var(cliActual, _) = await MinVerCli.Run(path, envVars : envVars);

            // assert
            Assert.Equal(expected, sdkActual);
            Assert.Equal(expected.Version, cliActual);
        }
Beispiel #7
0
        public static async Task HasDefaultVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            var expected = Package.WithVersion(0, 0, 0, new[] { "alpha", "0" });

            // act
            var(sdkActual, sdkOut) = await Sdk.BuildProject(path);

            var(cliActual, cliErr) = await MinVerCli.Run(path);

            // assert
            Assert.Equal(expected, sdkActual);
            Assert.Contains("MINVER1001", sdkOut, StringComparison.Ordinal);

            Assert.Equal(expected.Version, cliActual);
            Assert.Contains("not a valid Git working directory", cliErr, StringComparison.Ordinal);
        }
Beispiel #8
0
        public static async Task HasDefaultVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);

            await Git.Commit(path);

            var expected = Package.WithVersion(0, 0, 0, new[] { "alpha", "0" });

            // act
            var(sdkActual, _) = await Sdk.BuildProject(path);

            var(cliActual, _) = await MinVerCli.Run(path);

            // assert
            Assert.Equal(expected, sdkActual);
            Assert.Equal(expected.Version, cliActual);
        }
Beispiel #9
0
        public static async Task HasTagVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);

            await Git.Commit(path);

            await Git.AnnotatedTag(path, "2.3.4-alpha.5+build.6", "foo");

            var expected = Package.WithVersion(2, 3, 4, new[] { "alpha", "5" }, 0, "build.6");

            // act
            var(sdkActual, _) = await Sdk.BuildProject(path);

            var(cliActual, _) = await MinVerCli.Run(path);

            // assert
            Assert.Equal(expected, sdkActual);
            Assert.Equal(expected.Version, cliActual);
        }