Beispiel #1
0
        public void Should_Set_NoFallback_via_WithNoFallback()
        {
            var settings = new MinVerSettings()
                           .WithNoFallback();

            settings.NoFallback.Should().BeTrue();
        }
Beispiel #2
0
        public void Should_Set_ToolPath_via_WithToolPath()
        {
            var settings = new MinVerSettings()
                           .WithToolPath(@"c:\myCustomTools\minver.exe");

            settings.ToolPath.FullPath.Should().Be(@"c:/myCustomTools/minver.exe");
        }
Beispiel #3
0
        public void Should_Set_TagPrefix_via_WithTagPrefix()
        {
            var settings = new MinVerSettings()
                           .WithTagPrefix("v");

            settings.TagPrefix.Should().Be("v");
        }
Beispiel #4
0
        public void Should_Set_PreferGlobalTool_via_WithPreferGlobalTool()
        {
            var settings = new MinVerSettings()
                           .WithPreferGlobalTool();

            settings.PreferGlobalTool.Should().BeTrue();
        }
Beispiel #5
0
        public void Should_Set_MinimumMajorMinor_via_WithMinimumMajorMinor()
        {
            var settings = new MinVerSettings()
                           .WithMinimumMajorMinor("2.5");

            settings.MinimumMajorMinor.Should().Be("2.5");
        }
Beispiel #6
0
        public void Should_Set_Repo_via_WithRepo()
        {
            var settings = new MinVerSettings()
                           .WithRepo("./src");

            settings.Repo.FullPath.Should().Be("src");
        }
Beispiel #7
0
        public void Should_Set_BuildMetadata_via_WithBuildMetadata()
        {
            var settings = new MinVerSettings()
                           .WithBuildMetadata("abcdefg");

            settings.BuildMetadata.Should().Be("abcdefg");
        }
Beispiel #8
0
        public void Should_Set_DefaultPreReleasePhase_via_WithDefaultPreReleasePhase()
        {
            var settings = new MinVerSettings()
                           .WithDefaultPreReleasePhase("preview");

            settings.DefaultPreReleasePhase.Should().Be("preview");
        }
Beispiel #9
0
        public void Should_Set_AutoIncrement_via_WithAutoIncrement()
        {
            var settings = new MinVerSettings()
                           .WithAutoIncrement(MinVerAutoIncrement.Major);

            settings.AutoIncrement.Should().Be(MinVerAutoIncrement.Major);
        }
Beispiel #10
0
        public void Should_Set_WorkingDirectory_via_FromPath()
        {
            var settings = new MinVerSettings()
                           .FromPath("./src");

            settings.WorkingDirectory.FullPath.Should().Be("src");
        }
Beispiel #11
0
        public void Should_Set_Verbosity_via_WithVerbosity()
        {
            var settings = new MinVerSettings()
                           .WithVerbosity(MinVerVerbosity.Trace);

            settings.Verbosity.Should().Be(MinVerVerbosity.Trace);
        }
        public Task Should_Shallow_Clone_All_Properties()
        {
            var expected = new MinVerSettings
            {
                AutoIncrement          = MinVerAutoIncrement.Minor,
                BuildMetadata          = "123",
                DefaultPreReleasePhase = "preview",
                MinimumMajorMinor      = "1.2",
                Repo             = DirectoryPath.FromString("/repo/custom"),
                TagPrefix        = "v",
                PreferGlobalTool = true,
                NoFallback       = true,
                Verbosity        = MinVerVerbosity.Trace,
                ToolVerbosity    = DotNetVerbosity.Detailed,

                DiagnosticOutput      = true,
                ToolPath              = FilePath.FromString("/tools/custom/minver.exe"),
                ToolTimeout           = TimeSpan.FromMinutes(5),
                WorkingDirectory      = DirectoryPath.FromString("/working/folder"),
                NoWorkingDirectory    = true,
                ArgumentCustomization = s => s,
                EnvironmentVariables  = new Dictionary <string, string> {
                    { "MINVERTESTVAR", "SOMEVALUE" }
                },
                HandleExitCode = i => false,
            };

            return(Verifier.Verify(expected.Clone()));
        }
Beispiel #13
0
        public void Should_Shallow_Clone_All_Properties()
        {
            var expected = new MinVerSettings
            {
                AutoIncrement          = MinVerAutoIncrement.Minor,
                BuildMetadata          = "123",
                DefaultPreReleasePhase = "preview",
                MinimumMajorMinor      = "1.2",
                Repo             = DirectoryPath.FromString("/repo/custom"),
                TagPrefix        = "v",
                PreferGlobalTool = true,
                NoFallback       = true,
                Verbosity        = MinVerVerbosity.Trace,
                ToolVerbosity    = DotNetCoreVerbosity.Detailed,

                DiagnosticOutput      = true,
                ToolPath              = FilePath.FromString("/tools/custom/minver.exe"),
                ToolTimeout           = TimeSpan.FromMinutes(5),
                WorkingDirectory      = DirectoryPath.FromString("/working/folder"),
                NoWorkingDirectory    = true,
                ArgumentCustomization = s => s,
                EnvironmentVariables  = new Dictionary <string, string> {
                    { "MINVERTESTVAR", "SOMEVALUE" }
                },
                HandleExitCode = i => false,
            };

            var actual = expected.Clone();

            actual.AutoIncrement.Should().Be(expected.AutoIncrement);
            actual.BuildMetadata.Should().Be(expected.BuildMetadata);
            actual.DefaultPreReleasePhase.Should().Be(expected.DefaultPreReleasePhase);
            actual.MinimumMajorMinor.Should().Be(expected.MinimumMajorMinor);
            actual.Repo.Should().Be(expected.Repo);
            actual.TagPrefix.Should().Be(expected.TagPrefix);
            actual.PreferGlobalTool.Should().Be(expected.PreferGlobalTool);
            actual.NoFallback.Should().Be(expected.NoFallback);
            actual.Verbosity.Should().Be(expected.Verbosity);
            actual.ToolVerbosity.Should().Be(expected.ToolVerbosity);

            actual.DiagnosticOutput.Should().Be(expected.DiagnosticOutput);
            actual.ToolPath.Should().Be(expected.ToolPath);
            actual.ToolTimeout.Should().Be(expected.ToolTimeout);
            actual.WorkingDirectory.Should().Be(expected.WorkingDirectory);
            actual.NoWorkingDirectory.Should().Be(expected.NoWorkingDirectory);
            actual.ArgumentCustomization.Should().Be(expected.ArgumentCustomization);
            actual.EnvironmentVariables.Should().BeEquivalentTo(expected.EnvironmentVariables);
            actual.HandleExitCode.Should().BeEquivalentTo(expected.HandleExitCode);

            var properties = typeof(MinVerSettings)
                             .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy)
                             .Select(p => p.Name)
                             .ToList();

            // Sanity check & alarm to detect changes in properties that need to be considered in the cloning
            properties.Should().HaveCount(18);
        }