Beispiel #1
0
        public void Should_Not_Add_Recommended_You_Do_Not_Change_Elements_When_Provided()
        {
            var template = @"
            <RunSettings>
                <RunConfiguration>
                </RunConfiguration>
                <DataCollectionRunSettings>
                    <DataCollectors>
                        <DataCollector friendlyName='Code Coverage' enabled='{replacements.Enabled}'>
                            <Configuration>
                                <CodeCoverage>
                                <UseVerifiableInstrumentation>False</UseVerifiableInstrumentation>
                                <AllowLowIntegrityProcesses>False</AllowLowIntegrityProcesses>
                                <CollectFromChildProcesses>False</CollectFromChildProcesses>
                                <CollectAspDotNet>True</CollectAspDotNet>
                                </CodeCoverage>
                                <Format>Cobertura</Format>
                                <FCCGenerated/>
                            </Configuration>
                        </DataCollector>
                    </DataCollectors>
                </DataCollectionRunSettings>
            </RunSettings>";

            var runSettingsTemplate = new RunSettingsTemplate();
            var result = runSettingsTemplate.ReplaceTemplate(template, new RunSettingsTemplateReplacements(), true);

            XmlAssert.NoXmlDifferences(result.Replaced, template);
        }
Beispiel #2
0
        private void ConfiguredCustomReplaceTest(string custom, string expected, IRunSettingsTemplateReplacements replacements)
        {
            var runSettingsTemplate = new RunSettingsTemplate();

            var customTemplate = runSettingsTemplate.ConfigureCustom(custom);

            var replaced = runSettingsTemplate.Replace(customTemplate, replacements);

            XmlAssert.NoXmlDifferences(replaced, expected);
        }
        public async Task Should_Return_The_FineCodeCoverage_Labelled_PropertyGroup()
        {
            var coverageProjectSettingsProvider = new CoverageProjectSettingsProvider(null);
            var mockCoverageProject             = new Mock <ICoverageProject>();
            var fccLabelledPropertyGroup        = @"
    <PropertyGroup Label='FineCodeCoverage'>
        <Setting1/>
    </PropertyGroup>

";
            var projectFileXElement             = XElement.Parse($@"
<Project>
    {fccLabelledPropertyGroup}
</Project>
");

            mockCoverageProject.Setup(cp => cp.ProjectFileXElement).Returns(projectFileXElement);
            var coverageProject         = mockCoverageProject.Object;
            var coverageProjectSettings = await coverageProjectSettingsProvider.ProvideAsync(coverageProject);

            XmlAssert.NoXmlDifferences(coverageProjectSettings.ToString(), fccLabelledPropertyGroup);
        }
Beispiel #4
0
        public void Should_Be_Replaceable_With_Recommended_You_Do_Not_Change_Elements_When_Not_Provided(bool isDotNetFramework)
        {
            var runSettingsTemplate          = new RunSettingsTemplate();
            var template                     = runSettingsTemplate.ToString();
            var useVerifiableInstrumentation = isDotNetFramework ? "False" : "True";

            var replacements = new RunSettingsTemplateReplacements
            {
                AttributesExclude      = "<AttributesExclude/>",
                AttributesInclude      = "<AttributesInclude/>",
                CompanyNamesExclude    = "<CompanyNamesExclude/>",
                CompanyNamesInclude    = "<CompanyNamesInclude/>",
                FunctionsExclude       = "<FunctionsExclude/>",
                FunctionsInclude       = "<FunctionsInclude/>",
                ModulePathsInclude     = "<ModulePathsInclude/>",
                ModulePathsExclude     = "<ModulePathsExclude/>",
                PublicKeyTokensExclude = "<PublicKeyTokensExclude/>",
                PublicKeyTokensInclude = "<PublicKeyTokensInclude/>",
                SourcesExclude         = "<SourcesExclude/>",
                SourcesInclude         = "<SourcesInclude/>",

                Enabled          = "enabledreplaced",
                ResultsDirectory = "resultsdirectory",
                TestAdapter      = "testadapter"
            };

            var expected = XmlHelper.XmlDeclaration + $@"
            <RunSettings>
                <RunConfiguration>
                    <ResultsDirectory>{replacements.ResultsDirectory}</ResultsDirectory>
                    <TestAdaptersPaths>{replacements.TestAdapter}</TestAdaptersPaths>
                    <CollectSourceInformation>False</CollectSourceInformation>
                </RunConfiguration>
                <DataCollectionRunSettings>
                    <DataCollectors>
                        <DataCollector friendlyName='Code Coverage' enabled='{replacements.Enabled}'>
                            <Configuration>
                                <CodeCoverage>
                                <ModulePaths>
                                    <Exclude>
                                    {replacements.ModulePathsExclude}
                                    </Exclude>
                                    <Include>
                                    {replacements.ModulePathsInclude}
                                    </Include>
                                </ModulePaths>
                                <Functions>
                                    <Exclude>
                                    {replacements.FunctionsExclude}
                                    </Exclude>
                                    <Include>
                                    {replacements.FunctionsInclude}
                                    </Include>
                                </Functions>
                                <Attributes>
                                    <Exclude>
                                    {replacements.AttributesExclude}
                                    </Exclude>
                                    <Include>
                                    {replacements.AttributesInclude}
                                    </Include>
                                </Attributes>
                                <Sources>
                                    <Exclude>
                                    {replacements.SourcesExclude}
                                    </Exclude>
                                    <Include>
                                    {replacements.SourcesInclude}
                                    </Include>
                                </Sources>
                                <CompanyNames>
                                    <Exclude>
                                    {replacements.CompanyNamesExclude}
                                    </Exclude>
                                    <Include>
                                    {replacements.CompanyNamesInclude}
                                    </Include>
                                </CompanyNames>
                                <PublicKeyTokens>
                                    <Exclude>
                                    {replacements.PublicKeyTokensExclude}
                                    </Exclude>
                                    <Include>
                                    {replacements.PublicKeyTokensInclude}
                                    </Include>
                                </PublicKeyTokens>
                                <UseVerifiableInstrumentation>{useVerifiableInstrumentation}</UseVerifiableInstrumentation>
                                <AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
                                <CollectFromChildProcesses>True</CollectFromChildProcesses>
                                <CollectAspDotNet>False</CollectAspDotNet>
                                </CodeCoverage>
                                <Format>Cobertura</Format>
                                <FCCGenerated/>
                            </Configuration>
                        </DataCollector>
                    </DataCollectors>
                </DataCollectionRunSettings>
            </RunSettings>";

            var result = runSettingsTemplate.ReplaceTemplate(template, replacements, isDotNetFramework);

            XmlAssert.NoXmlDifferences(result.Replaced, expected);
        }
        private void TestAddFCCSettings(string runSettings, string expectedFccRunSettings, IRunSettingsTemplateReplacements runSettingsTemplateReplacements)
        {
            var actualRunSettings = AddFCCSettings(runSettings, runSettingsTemplateReplacements);

            XmlAssert.NoXmlDifferences(actualRunSettings, expectedFccRunSettings);
        }