Пример #1
0
        public void Should_Run_Local_Tool_By_Running_dotnet_minver()
        {
            var fixture = new MinVerToolFixture(_log);
            var result  = fixture.Run();

            result.Path.FullPath.Should().Be(fixture.LocalTool.DefaultToolPath.FullPath);
            result.Args.Should().Be("minver");
        }
Пример #2
0
        public void Should_Return_MinVer_Calculated_Version_When_Tag_Found_Default_Verbosity()
        {
            var fixture = new MinVerToolFixture(_log);

            fixture.LocalTool.StandardOutput = MinVerToolOutputs.OutputWhenTagFoundDefaultVerbosity;

            var result = fixture.Run();

            result.Version.ToString().Should().Be("5.0.1-alpha.0.8");
        }
Пример #3
0
        public void Should_Return_MinVer_Calculated_Version_When_Not_A_Git_Repository()
        {
            var fixture = new MinVerToolFixture(_log);

            fixture.LocalTool.StandardOutput = MinVerToolOutputs.OutputWhenNotAGitRepo;

            var result = fixture.Run();

            result.Version.ToString().Should().Be("0.0.0-alpha.0");
        }
Пример #4
0
        public void Should_Return_MinVer_Calculated_Version_When_Tag_Found_Verbosity_Error()
        {
            var fixture = new MinVerToolFixture(_log);

            fixture.LocalTool.StandardOutput = MinVerToolOutputs.OutputWhenTagFoundVerbosityError;

            var result = fixture.Run();

            result.Version.ToString().Should().Be("1.2.3-preview.0.4");
        }
Пример #5
0
        public void Should_Return_MinVer_Calculated_Version_When_Tag_Not_Found()
        {
            var fixture = new MinVerToolFixture(_log);

            fixture.LocalTool.StandardOutput = MinVerToolOutputs.OutputWhenTagNotFound;

            var result = fixture.Run();

            result.Version.ToString().Should().Be("0.0.0-alpha.0.42");
        }
Пример #6
0
        public void Should_Throw_Cake_Exception_If_Cant_Parse_MinVer_Version()
        {
            var fixture = new MinVerToolFixture(_log);

            fixture.LocalTool.StandardOutput = new[] { "abcd" };

            fixture.Invoking(f => f.Run())
            .Should().ThrowExactly <CakeException>()
            .WithMessage("Version 'abcd' is not valid.");
        }
Пример #7
0
        public void Should_Add_Default_Pre_Release_Phase_Arguments()
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { DefaultPreReleasePhase = "preview" },
            };

            var result = fixture.Run();

            result.Args.Should().Be("minver --default-pre-release-phase \"preview\"");
        }
Пример #8
0
        public void Should_Run_Local_Tool_First_By_Default()
        {
            var fixture = new MinVerToolFixture(_log);

            var result = fixture.Run();

            fixture.LocalTool.ShouldHaveRunOnce();
            fixture.GlobalTool.ShouldNotHaveRun();

            result.Version.Should().Be(MinVerToolOutputs.DefaultVersionForLocalTool);
        }
Пример #9
0
        public void Should_Add_Verbosity_To_Arguments(MinVerVerbosity?verbosity, string expectedArgs)
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { Verbosity = verbosity },
            };

            var result = fixture.Run();

            result.Args.Should().Be(expectedArgs);
        }
Пример #10
0
        public void Should_Add_Tag_Prefix_Arguments()
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { TagPrefix = "v" },
            };

            var result = fixture.Run();

            result.Args.Should().Be("minver --tag-prefix \"v\"");
        }
Пример #11
0
        public void Should_Add_Repo_Arguments()
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { Repo = "./src" },
            };

            var result = fixture.Run();

            result.Args.Should().Be("minver --repo \"src\"");
        }
Пример #12
0
        public void Should_Add_Minimum_Major_Minor_Arguments()
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { MinimumMajorMinor = "2.0" },
            };

            var result = fixture.Run();

            result.Args.Should().Be("minver --minimum-major-minor \"2.0\"");
        }
Пример #13
0
        public void Should_Add_Build_Metadata_Arguments()
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { BuildMetadata = "1234abc" },
            };

            var result = fixture.Run();

            result.Args.Should().Be("minver --build-metadata \"1234abc\"");
        }
Пример #14
0
        public void Should_Add_Auto_Increment_To_Arguments(MinVerAutoIncrement?autoIncrement, string expectedArgs)
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { AutoIncrement = autoIncrement },
            };

            var result = fixture.Run();

            result.Args.Should().Be(expectedArgs);
        }
Пример #15
0
        public void Should_Run_Global_Tool_By_Running_minver()
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { PreferGlobalTool = true },
            };

            var result = fixture.Run();

            result.Path.FullPath.Should().Be(fixture.GlobalTool.DefaultToolPath.FullPath);
            result.Args.Should().BeEmpty();
        }
Пример #16
0
        public void Should_Throw_If_Settings_Are_Null()
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = null,
            };

            fixture.GivenDefaultToolDoNotExist();

            fixture.Invoking(f => f.Run())
            .Should().ThrowExactly <ArgumentNullException>()
            .And.ParamName.Should().Be("settings");
        }
Пример #17
0
        public void Should_Run_Global_Tool_First_If_PreferGlobalTool()
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { PreferGlobalTool = true },
            };

            var result = fixture.Run();

            fixture.GlobalTool.ShouldHaveRunOnce();
            fixture.LocalTool.ShouldNotHaveRun();

            result.Version.Should().Be(MinVerToolOutputs.DefaultVersionForGlobalTool);
        }
Пример #18
0
        public void Should_Not_Fallback_If_NoFallback_Is_True()
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { NoFallback = true },
            };

            fixture.GivenLocalToolFailsToRun();

            fixture.Invoking(f => f.Run())
            .Should().ThrowExactly <CakeException>()
            .And.Message.Should().StartWith("MinVer: Process returned an error (exit code 1)");

            fixture.LocalTool.ShouldHaveRunOnce();
            fixture.GlobalTool.ShouldNotHaveRun();
        }
Пример #19
0
        public void Should_Run_Local_Tool_First_By_Default_And_Fallback_To_Global_Tool()
        {
            var fixture = new MinVerToolFixture(_log);

            fixture.GivenLocalToolFailsToRun();

            var result = fixture.Run();

            fixture.LocalTool.ShouldHaveRunOnce();
            fixture.GlobalTool.ShouldHaveRunOnce();

            fixture.LocalTool.ShouldHaveRunFirst();
            fixture.GlobalTool.ShouldHaveRunSecond();

            result.Version.Should().Be(MinVerToolOutputs.DefaultVersionForGlobalTool);
        }
Пример #20
0
        public void Should_Run_Global_Tool_First_If_PreferGlobalTool_And_Fallback_To_Local_Tool()
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { PreferGlobalTool = true },
            };

            fixture.GivenGlobalToolFailsToRun();

            var result = fixture.Run();

            fixture.GlobalTool.ShouldHaveRunOnce();
            fixture.LocalTool.ShouldHaveRunOnce();

            fixture.GlobalTool.ShouldHaveRunFirst();
            fixture.LocalTool.ShouldHaveRunSecond();

            result.Version.Should().Be(MinVerToolOutputs.DefaultVersionForLocalTool);
        }
Пример #21
0
        public void Should_Prefer_Global_Tool_using_ToolPath_When_ToolPath_Is_Set()
        {
            var fixture = new MinVerToolFixture(_log);

            fixture.GivenLocalToolIsNotInstalled();
            fixture.GivenGlobalToolIsNotInstalled();

            var customToolExePath = fixture.DefaultToolPath.GetDirectory().CombineWithFilePath("customLocation/custom.exe");

            fixture.FileSystem.CreateFile(customToolExePath);

            fixture.Settings.ToolPath = customToolExePath;

            var result = fixture.Run();

            fixture.GlobalTool.ShouldHaveRunOnce();
            fixture.LocalTool.ShouldNotHaveRun();

            result.Version.Should().Be(MinVerToolOutputs.DefaultVersionForGlobalTool);
        }
Пример #22
0
        public void Should_Add_Tag_Prefix_Arguments_From_Environment_Variable(string argValue, string envVarOverrideValue, string envVarValue, string expected)
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { TagPrefix = argValue },
            };

            if (!string.IsNullOrWhiteSpace(envVarOverrideValue))
            {
                fixture.Settings.EnvironmentVariables[MinVerEnvironmentVariables.MINVERTAGPREFIX] = envVarOverrideValue;
            }

            if (!string.IsNullOrWhiteSpace(envVarValue))
            {
                fixture.Environment.SetEnvironmentVariable(MinVerEnvironmentVariables.MINVERTAGPREFIX, envVarValue);
            }

            var result = fixture.Run();

            result.Args.Should().Be($"minver --tag-prefix \"{expected}\"");
        }
Пример #23
0
        public void Should_Add_Minimum_Major_Minor_Arguments_From_Environment_Variable(string argValue, string envVarOverrideValue, string envVarValue, string expected)
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { MinimumMajorMinor = argValue },
            };

            if (!string.IsNullOrWhiteSpace(envVarOverrideValue))
            {
                fixture.Settings.EnvironmentVariables[MinVerEnvironmentVariables.MINVERMINIMUMMAJORMINOR] = envVarOverrideValue;
            }

            if (!string.IsNullOrWhiteSpace(envVarValue))
            {
                fixture.Environment.SetEnvironmentVariable(MinVerEnvironmentVariables.MINVERMINIMUMMAJORMINOR, envVarValue);
            }

            var result = fixture.Run();

            result.Args.Should().Be($"minver --minimum-major-minor \"{expected}\"");
        }
Пример #24
0
        public void Should_Add_Default_PreRelease_Phase_Arguments_From_Environment_Variable(string argValue, string envVarOverrideValue, string envVarValue, string expected)
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { DefaultPreReleasePhase = argValue },
            };

            if (!string.IsNullOrWhiteSpace(envVarOverrideValue))
            {
                fixture.Settings.EnvironmentVariables[MinVerEnvironmentVariables.MINVERDEFAULTPRERELEASEPHASE] = envVarOverrideValue;
            }

            if (!string.IsNullOrWhiteSpace(envVarValue))
            {
                fixture.Environment.SetEnvironmentVariable(MinVerEnvironmentVariables.MINVERDEFAULTPRERELEASEPHASE, envVarValue);
            }

            var result = fixture.Run();

            result.Args.Should().Be($"minver --default-pre-release-phase \"{expected}\"");
        }
Пример #25
0
        public void Should_Add_Build_Metadata_Arguments_From_Environment_Variable(string argValue, string envVarOverrideValue, string envVarValue, string expected)
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { BuildMetadata = argValue },
            };

            if (!string.IsNullOrWhiteSpace(envVarOverrideValue))
            {
                fixture.Settings.EnvironmentVariables[MinVerEnvironmentVariables.MINVERBUILDMETADATA] = envVarOverrideValue;
            }

            if (!string.IsNullOrWhiteSpace(envVarValue))
            {
                fixture.Environment.SetEnvironmentVariable(MinVerEnvironmentVariables.MINVERBUILDMETADATA, envVarValue);
            }

            var result = fixture.Run();

            result.Args.Should().Be($"minver --build-metadata \"{expected}\"");
        }
Пример #26
0
        public void Should_Not_Fallback_If_ToolPath_Is_Set()
        {
            var fixture = new MinVerToolFixture(_log);

            fixture.GivenLocalToolIsNotInstalled();
            fixture.GivenGlobalToolIsNotInstalled();

            var customToolExePath = fixture.DefaultToolPath.GetDirectory().CombineWithFilePath("customLocation/custom.exe");

            fixture.FileSystem.CreateFile(customToolExePath);

            fixture.Settings.ToolPath = customToolExePath;

            fixture.GivenGlobalToolFailsToRun();

            fixture.Invoking(f => f.Run())
            .Should().ThrowExactly <CakeException>()
            .And.Message.Should().StartWith("MinVer: Process returned an error (exit code 1)");

            fixture.GlobalTool.ShouldHaveRunOnce();
            fixture.LocalTool.ShouldNotHaveRun();
        }
Пример #27
0
        public void Should_Add_Verbosity_Arguments_From_Environment_Variable(MinVerVerbosity?argValue, MinVerVerbosity?envVarOverrideValue, MinVerVerbosity?envVarValue, MinVerVerbosity expected)
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { Verbosity = argValue },
            };

            if (envVarOverrideValue.HasValue)
            {
                fixture.Settings.EnvironmentVariables[MinVerEnvironmentVariables.MINVERVERBOSITY] =
                    envVarOverrideValue.Value.ToString().ToLowerInvariant();
            }

            if (envVarValue.HasValue)
            {
                fixture.Environment.SetEnvironmentVariable(MinVerEnvironmentVariables.MINVERVERBOSITY,
                                                           envVarValue.Value.ToString().ToLowerInvariant());
            }

            var result = fixture.Run();

            result.Args.Should().Be($"minver --verbosity {expected.ToString().ToLowerInvariant()}");
        }
Пример #28
0
        public void Should_Add_Auto_Increment_Arguments_From_Environment_Variable(MinVerAutoIncrement?argValue, MinVerAutoIncrement?envVarOverrideValue, MinVerAutoIncrement?envVarValue, MinVerAutoIncrement expected)
        {
            var fixture = new MinVerToolFixture(_log)
            {
                Settings = { AutoIncrement = argValue },
            };

            if (envVarOverrideValue.HasValue)
            {
                fixture.Settings.EnvironmentVariables[MinVerEnvironmentVariables.MINVERAUTOINCREMENT] =
                    envVarOverrideValue.Value.ToString().ToLowerInvariant();
            }

            if (envVarValue.HasValue)
            {
                fixture.Environment.SetEnvironmentVariable(MinVerEnvironmentVariables.MINVERAUTOINCREMENT,
                                                           envVarValue.Value.ToString().ToLowerInvariant());
            }

            var result = fixture.Run();

            result.Args.Should().Be($"minver --auto-increment {expected.ToString().ToLowerInvariant()}");
        }