Пример #1
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(actual, _, _) = await Sdk.BuildProject(path);

        var(cliStandardOutput, _) = await MinVerCli.ReadAsync(path);

        // assert
        Assert.Equal(expected, actual);
        Assert.Equal(expected.Version, cliStandardOutput.Trim());
    }
Пример #2
0
        public static async Task HasDefaultVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(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("No commits found", sdkOut, StringComparison.Ordinal);

            Assert.Equal(expected.Version, cliActual);
            Assert.Contains("No commits found", cliErr, StringComparison.Ordinal);
        }
Пример #3
0
    public static async Task DoesNotRecreatePackage(bool multiTarget)
    {
        // arrange
        var path = MethodBase.GetCurrentMethod().GetTestDirectory(multiTarget);
        await Sdk.CreateProject(path, multiTarget : multiTarget);

        await Git.Init(path);

        await Git.Commit(path);

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

        var(_, standardOutput, _) = await Sdk.BuildProject(path);

        Assert.Contains("Successfully created package", standardOutput, StringComparison.OrdinalIgnoreCase);

        // act
        (standardOutput, _) = await Sdk.Pack(path);

        // assert
        Assert.DoesNotContain("Successfully created package", standardOutput, StringComparison.OrdinalIgnoreCase);
    }
Пример #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, "2.3.4-alpha.5+build.6");

            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);
        }
Пример #5
0
        public static async Task AreSet()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            var envVars = ("MinVerVersionOverride".ToAltCase(), "2.3.4-alpha-x.5+build.6");

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

            // assert
            Assert.Contains("MinVer: [output] MinVerVersion=2.3.4-alpha-x.5+build.6", standardOutput, StringComparison.Ordinal);
            Assert.Contains("MinVer: [output] MinVerMajor=2", standardOutput, StringComparison.Ordinal);
            Assert.Contains("MinVer: [output] MinVerMinor=3", standardOutput, StringComparison.Ordinal);
            Assert.Contains("MinVer: [output] MinVerPatch=4", standardOutput, StringComparison.Ordinal);
            Assert.Contains("MinVer: [output] MinVerPreRelease=alpha-x.5", standardOutput, StringComparison.Ordinal);
            Assert.Contains("MinVer: [output] MinVerBuildMetadata=build.6", standardOutput, StringComparison.Ordinal);
            Assert.Contains("MinVer: [output] AssemblyVersion=2.0.0.0", standardOutput, StringComparison.Ordinal);
            Assert.Contains("MinVer: [output] FileVersion=2.3.4.0", standardOutput, StringComparison.Ordinal);
            Assert.Contains("MinVer: [output] PackageVersion=2.3.4-alpha-x.5+build.6", standardOutput, StringComparison.Ordinal);
            Assert.Contains("MinVer: [output] Version=2.3.4-alpha-x.5+build.6", standardOutput, StringComparison.Ordinal);
        }
Пример #6
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(actual, _, _) = await Sdk.BuildProject(path);

        var(cliStandardOutput, _) = await MinVerCli.ReadAsync(path);

        // assert
        Assert.Equal(expected, actual);
        Assert.Equal(expected.Version, cliStandardOutput.Trim());
    }
        public static async Task IsUsed()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

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

            // act
            // SemVer doesn't allow multiple plus signs, but MinVer doesn't care
            string @out      = null;
            var    exception = await Record.ExceptionAsync(async() => (_, @out) = await Sdk.BuildProject(path, envVars: envVars));

            if (exception != null)
            {
                @out = exception.Message;
            }

            // assert
            Assert.Contains("MinVer: [output] MinVerVersion=2.3.4-alpha-x.5+build.6+7", @out);
            Assert.Contains("MinVer: [output] MinVerBuildMetadata=build.6+7", @out);
            Assert.Contains("MinVer: [output] PackageVersion=2.3.4-alpha-x.5+build.6+7", @out);
            Assert.Contains("MinVer: [output] Version=2.3.4-alpha-x.5+build.6+7", @out);
        }