Ejemplo n.º 1
0
        public void Should_Be_Empty_String_Replacement_When_Null()
        {
            var msCodeCoverageOptions = new TestCoverageProjectOptions
            {
                IncludeTestAssembly = true
            };

            var coverageProject = CreateCoverageProject(mock => mock.Setup(cp => cp.Settings).Returns(msCodeCoverageOptions));
            var replacements    = runSettingsTemplateReplacementsFactory.Create(coverageProject, null);


            ReplacementsAssertions.AssertAllEmpty(replacements);
        }
Ejemplo n.º 2
0
        public void Should_Create_Distinct_Element_Replacements()
        {
            var msCodeCoverageOptions = new TestCoverageProjectOptions
            {
                FunctionsExclude       = new[] { "FunctionExclude1", "FunctionExclude1" },
                FunctionsInclude       = new[] { "FunctionInclude1", "FunctionInclude1" },
                CompanyNamesExclude    = new[] { "CompanyNameExclude1", "CompanyNameExclude1" },
                CompanyNamesInclude    = new[] { "CompanyNameInclude1", "CompanyNameInclude1" },
                AttributesExclude      = new[] { "AttributeExclude1", "AttributeExclude1" },
                AttributesInclude      = new[] { "AttributeInclude1", "AttributeInclude1" },
                PublicKeyTokensExclude = new[] { "PublicKeyTokenExclude1", "PublicKeyTokenExclude1" },
                PublicKeyTokensInclude = new[] { "PublicKeyTokenInclude1", "PublicKeyTokenInclude1" },
                SourcesExclude         = new[] { "SourceExclude1", "SourceExclude1" },
                SourcesInclude         = new[] { "SourceInclude1", "SourceInclude1" },
                ModulePathsExclude     = new[] { "ModulePathExclude1", "ModulePathExclude1" },
                ModulePathsInclude     = new[] { "ModulePathInclude1", "ModulePathInclude1" },
                IncludeTestAssembly    = true
            };

            var coverageProject = CreateCoverageProject(mock => mock.Setup(cp => cp.Settings).Returns(msCodeCoverageOptions));
            var replacements    = runSettingsTemplateReplacementsFactory.Create(coverageProject, null);

            void AssertReplacement(string replacement, string replacementProperty, bool isInclude)
            {
                var ie = isInclude ? "Include" : "Exclude";

                Assert.AreEqual($"<{replacementProperty}>{replacementProperty}{ie}1</{replacementProperty}>", replacement);
            }

            AssertReplacement(replacements.ModulePathsExclude, "ModulePath", false);
            AssertReplacement(replacements.ModulePathsInclude, "ModulePath", true);

            AssertReplacement(replacements.FunctionsExclude, "Function", false);
            AssertReplacement(replacements.FunctionsInclude, "Function", true);
            AssertReplacement(replacements.CompanyNamesExclude, "CompanyName", false);
            AssertReplacement(replacements.CompanyNamesInclude, "CompanyName", true);
            AssertReplacement(replacements.AttributesExclude, "Attribute", false);
            AssertReplacement(replacements.AttributesInclude, "Attribute", true);
            AssertReplacement(replacements.PublicKeyTokensExclude, "PublicKeyToken", false);
            AssertReplacement(replacements.PublicKeyTokensInclude, "PublicKeyToken", true);
            AssertReplacement(replacements.SourcesExclude, "Source", false);
            AssertReplacement(replacements.SourcesInclude, "Source", true);
        }
Ejemplo n.º 3
0
        public void Should_Have_ModulePathsInclude_Replacements_From_IncludedReferencedProjects_And_Settings()
        {
            var msCodeCoverageOptions = new TestCoverageProjectOptions
            {
                ModulePathsInclude  = new[] { "FromSettings" },
                IncludeTestAssembly = true
            };

            var coverageProject = CreateCoverageProject(mock =>
            {
                mock.Setup(cp => cp.Settings).Returns(msCodeCoverageOptions);
                mock.Setup(cp => cp.IncludedReferencedProjects).Returns(new List <string>
                {
                    "ModuleName"
                });
            });

            var replacements = runSettingsTemplateReplacementsFactory.Create(coverageProject, null);
            var expectedModulePathsInclude = $"{ModulePathElement(MsCodeCoverageRegex.RegexModuleName("ModuleName"))}{ModulePathElement("FromSettings")}";

            Assert.AreEqual(expectedModulePathsInclude, replacements.ModulePathsInclude);
        }