示例#1
0
        public void MakeRunsettingsCompatibleShouldNotDeleteOldRunConfigurationNode()
        {
            var settings = @"<RunSettings>
                                <RunConfiguration>
                                    <DesignMode>False</DesignMode>
                                    <CollectSourceInformation>False</CollectSourceInformation>
                                    <TargetPlatform>x86</TargetPlatform>
                                    <TargetFrameworkVersion>net46</TargetFrameworkVersion>
                                    <TestAdaptersPaths>dummypath</TestAdaptersPaths>
                                    <ResultsDirectory>dummypath</ResultsDirectory>
                                    <SolutionDirectory>dummypath</SolutionDirectory>
                                    <MaxCpuCount>2</MaxCpuCount>
                                    <DisableParallelization>False</DisableParallelization>
                                    <DisableAppDomain>False</DisableAppDomain>
                                </RunConfiguration>
                            </RunSettings>";

            var result = InferRunSettingsHelper.MakeRunsettingsCompatible(settings);

            Assert.IsTrue(result.IndexOf("TargetPlatform", StringComparison.OrdinalIgnoreCase) > 0);
            Assert.IsTrue(result.IndexOf("TargetFrameworkVersion", StringComparison.OrdinalIgnoreCase) > 0);
            Assert.IsTrue(result.IndexOf("TestAdaptersPaths", StringComparison.OrdinalIgnoreCase) > 0);
            Assert.IsTrue(result.IndexOf("ResultsDirectory", StringComparison.OrdinalIgnoreCase) > 0);
            Assert.IsTrue(result.IndexOf("SolutionDirectory", StringComparison.OrdinalIgnoreCase) > 0);
            Assert.IsTrue(result.IndexOf("MaxCpuCount", StringComparison.OrdinalIgnoreCase) > 0);
            Assert.IsTrue(result.IndexOf("DisableParallelization", StringComparison.OrdinalIgnoreCase) > 0);
            Assert.IsTrue(result.IndexOf("DisableAppDomain", StringComparison.OrdinalIgnoreCase) > 0);
        }
示例#2
0
        public void MakeRunsettingsCompatibleShouldDeleteNewlyAddedRunConfigurationNode()
        {
            var settings = @"<RunSettings><RunConfiguration><DesignMode>False</DesignMode><CollectSourceInformation>False</CollectSourceInformation></RunConfiguration></RunSettings>";

            var result = InferRunSettingsHelper.MakeRunsettingsCompatible(settings);

            Assert.IsTrue(result.IndexOf("DesignMode", StringComparison.OrdinalIgnoreCase) < 0);
        }
示例#3
0
        /// <summary>
        /// This function will remove the unknown run settings nodes from the run settings strings.
        /// This is necessary because older test hosts may throw exceptions when encountering
        /// unknown nodes.
        /// </summary>
        /// 
        /// <param name="runsettingsXml">Run settings string.</param>
        /// 
        /// <returns>The run settings after removing non-required nodes.</returns>
        public string RemoveNodesFromRunsettingsIfRequired(string runsettingsXml, Action<TestMessageLevel, string> logMessage)
        {
            var updatedRunSettingsXml = runsettingsXml;
            if (!this.makeRunsettingsCompatibleSet)
            {
                this.CompatIssueWithVersionCheckAndRunsettings();
            }

            if (this.makeRunsettingsCompatible)
            {
                logMessage.Invoke(TestMessageLevel.Warning, CrossPlatEngineResources.OldTestHostIsGettingUsed);
                updatedRunSettingsXml = InferRunSettingsHelper.MakeRunsettingsCompatible(runsettingsXml);
            }

            return updatedRunSettingsXml;
        }