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"); }
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"); }
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"); }
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"); }
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"); }
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."); }
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\""); }
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); }
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); }
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\""); }
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\""); }
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\""); }
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\""); }
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); }
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(); }
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"); }
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); }
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(); }
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); }
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); }
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); }
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}\""); }
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}\""); }
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}\""); }
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}\""); }
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(); }
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()}"); }
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()}"); }