public void Should_Set_Verbose_Value()
        {
            // Given
            var settings = new CodecovSettings
            {
                // When
                Verbose = true,
            };

            // Then
            settings.Verbose.Should().BeTrue();
        }
        public void Should_Set_DisableNetwork_Value()
        {
            // Given
            var settings = new CodecovSettings
            {
                // When
                DisableNetwork = true
            };

            // Then
            settings.DisableNetwork.Should().BeTrue();
        }
        public void Should_Set_Dump_Value()
        {
            // Given
            var settings = new CodecovSettings
            {
                // When
                Dump = true
            };

            // Then
            settings.Dump.Should().BeTrue();
        }
        public void Should_Set_Required_Value()
        {
            // Given
            var settings = new CodecovSettings
            {
                // When
                Required = true
            };

            // Then
            settings.Required.Should().BeTrue();
        }
        public void Should_Set_NoColor_Value()
        {
            // Given
            var settings = new CodecovSettings
            {
                // When
                NoColor = true
            };

            // Then
            settings.NoColor.Should().BeTrue();
        }
        public void Should_Set_Branch_Value()
        {
            // Given
            var expected = "next";
            var settings = new CodecovSettings
            {
                // When
                Branch = expected
            };

            // Then
            settings.Branch.Should().Be(expected);
        }
        public void Should_Set_Url_Value()
        {
            // Given
            var expected = new Uri("https://localhost.com/test/server");
            var settings = new CodecovSettings
            {
                // When
                Url = expected
            };

            // Then
            settings.Url.Should().Be(expected);
        }
        public void Should_Set_Token_Value()
        {
            // Given
            var expected = Guid.NewGuid().ToString();
            var settings = new CodecovSettings
            {
                // When
                Token = expected
            };

            // Then
            settings.Token.Should().Be(expected);
        }
        public void Should_Set_Feature_Value()
        {
            // Given
            var expected = new[] { "s3" };
            var settings = new CodecovSettings
            {
                // When
                Features = expected
            };

            // Then
            settings.Features.Should().HaveCount(expected.Length).And.BeSameAs(expected);
        }
        public void Should_Set_Slug_Value()
        {
            // Given
            var expected = "my-test-slug";
            var settings = new CodecovSettings
            {
                // When
                Slug = expected
            };

            // Then
            settings.Slug.Should().Be(expected);
        }
        public void Should_Set_Pr_Value()
        {
            // Given
            var expected = "512";
            var settings = new CodecovSettings
            {
                // When
                Pr = expected
            };

            // Then
            settings.Pr.Should().Be(expected);
        }
        public void Should_Set_Name_Value()
        {
            // Given
            var expected = "Some Name";
            var settings = new CodecovSettings
            {
                // When
                Name = expected
            };

            // Then
            settings.Name.Should().Be(expected);
        }
        public void Should_Set_Flags_Value()
        {
            // Given
            var expected = "Integration";
            var settings = new CodecovSettings
            {
                // When
                Flags = expected
            };

            // Then
            settings.Flags.Should().Be(expected);
        }
        public void Should_Set_Files_Value()
        {
            // Given
            var expected = new[] { "file1.txt", "file2.xml" };
            var settings = new CodecovSettings
            {
                // When
                Files = expected
            };

            // Then
            settings.Files.Should().HaveCount(expected.Length).And.BeSameAs(expected);
        }
        public void Should_Set_Build_Value()
        {
            // Given
            var expected = "543";
            var settings = new CodecovSettings
            {
                // When
                Build = expected
            };

            // Then
            settings.Build.Should().Be(expected);
        }
        public void Should_Set_Root_Value()
        {
            // Given
            var expected = (DirectoryPath)"C:/test/root";
            var settings = new CodecovSettings
            {
                // When
                Root = expected
            };

            // Then
            settings.Root.Should().BeEquivalentTo(expected);
        }
        public void Should_Set_Commit_Value()
        {
            // Given
            var expected = "02eecc9564a8f89ddf13cf63b615cf08adee23cc";
            var settings = new CodecovSettings
            {
                // When
                Commit = expected
            };

            // Then
            settings.Commit.Should().Be(expected);
        }
        public void Should_Set_Tag_Value()
        {
            // Given
            var expected = "v1.0.0";
            var settings = new CodecovSettings
            {
                // When
                Tag = expected
            };

            // Then
            settings.Tag.Should().Be(expected);
        }
        public void Should_Set_Envs_Value()
        {
            // Given
            var expected = new[] { "APPVEYOR_IMAGE", "TESTING" };
            var settings = new CodecovSettings
            {
                // When
                Envs = expected
            };

            // Then
            settings.Envs.Should().HaveCount(expected.Length).And.BeSameAs(expected);
        }
        public void Should_Remove_Empty_String_Value(string value)
        {
            // Given
            var settings = new CodecovSettings
            {
                Tag = "v1.1.0"
            };

            // When
            settings.Tag = value;

            // Then
            settings.Tag.Should().BeNull();
        }
        public void Should_Use_Same_Settings_As_Specified()
        {
            var fixture = new CodecovAliasesFixture();

            var expected = new CodecovSettings
            {
                Branch = "MyBRanch",
                Build  = "MyBuild"
            };

            fixture.Settings = expected;

            var result = fixture.Run();

            result.Args.Should().ContainAll(new[]
            {
                $"--branch \"{expected.Branch}\"",
                $"--build \"{expected.Build}\""
            });
        }
Example #22
0
    public override void Run(Context context)
    {
        var coverageFiles = new List <FilePath>();

        if (context.AppVeyor)
        {
            foreach (var project in context.Projects.Where(x => x.UnitTests))
            {
                context.Information("Executing Code Coverage for Project {0}...", project.Name);

                var dotNetCoreCoverage = context.CodeCoverage
                                         .CombineWithFilePath(project.Name + "-netcoreapp3.1.xml");
                coverageFiles.Add(dotNetCoreCoverage);

                context.Coverlet(project, new CoverletToolSettings()
                {
                    Configuration = context.Configuration,
                    Framework     = "netcoreapp3.1",
                    Output        = dotNetCoreCoverage.FullPath
                });

                if (context.IsRunningOnWindows())
                {
                    var dotNetFrameworkCoverage = context.CodeCoverage
                                                  .CombineWithFilePath(project.Name + "-net46.xml");
                    coverageFiles.Add(dotNetFrameworkCoverage);

                    context.Coverlet(project, new CoverletToolSettings
                    {
                        Configuration = context.Configuration,
                        Framework     = "net46",
                        Output        = dotNetFrameworkCoverage.FullPath
                    });
                }

                context.Information("Uploading Coverage Files: {0}", string.Join(",", coverageFiles.Select(path => path.GetFilename().ToString())));

                var buildVersion = $"{context.Version.FullSemVer}.build.{context.EnvironmentVariable("APPVEYOR_BUILD_NUMBER")}";

                var userProfilePath = context.EnvironmentVariable("USERPROFILE");
                var codecovPath     = new DirectoryPath(userProfilePath)
                                      .CombineWithFilePath(".nuget\\packages\\codecov\\1.12.4\\tools\\codecov.exe");

                context.Tools.RegisterFile(codecovPath);

                foreach (var coverageFile in coverageFiles)
                {
                    var settings = new CodecovSettings
                    {
                        Files   = new[] { coverageFile.MakeAbsolute(context.Environment).FullPath },
                        Verbose = true,
                        EnvironmentVariables = new Dictionary <string, string>()
                        {
                            { "APPVEYOR_BUILD_VERSION", buildVersion }
                        }
                    };

                    context.Codecov(settings);
                }
            }
        }
    }