diff --git a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs index d97856db80..e2cf3529b8 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/RunSettingsProviderExtensions.cs @@ -109,10 +109,8 @@ private static string AddDefaultRunSettings(string runSettings) var document = new XmlDocument(); document.Load(reader); - var navigator = document.CreateNavigator(); - - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, architecture, framework, defaultResultsDirectory); - return navigator.OuterXml; + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(document, architecture, framework, defaultResultsDirectory); + return document.OuterXml; } } diff --git a/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlRunSettingsUtilities.cs b/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlRunSettingsUtilities.cs index d45c31f47b..dd1c79dd5d 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlRunSettingsUtilities.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Utilities/XmlRunSettingsUtilities.cs @@ -212,7 +212,14 @@ public static IXPathNavigable CreateDefaultRunSettings() #if NET451 return doc; #else - return doc.ToXPathNavigable(); + // Xmldocument doesn't inherit from XmlDocument for netcoreapp2.0 + var ret = doc as IXPathNavigable; + if (ret == null) + { + return doc.ToXPathNavigable(); + } + + return ret; #endif } diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index 5b94893702..9149f79185 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -69,7 +69,7 @@ public static string MakeRunsettingsCompatible(string runsettingsXml) { EqtTrace.Error("InferRunSettingsHelper.MakeRunsettingsCompatible: Unable to navigate to RunConfiguration. Current node: " + runSettingsNavigator.LocalName); } - else if(runSettingsNavigator.HasChildren) + else if (runSettingsNavigator.HasChildren) { var listOfInValidRunConfigurationSettings = new List(); @@ -90,7 +90,7 @@ public static string MakeRunsettingsCompatible(string runsettingsXml) runSettingsNavigator.MoveToFirstChild(); do { - if(!listOfValidRunConfigurationSettings.Contains(runSettingsNavigator.LocalName)) + if (!listOfValidRunConfigurationSettings.Contains(runSettingsNavigator.LocalName)) { listOfInValidRunConfigurationSettings.Add(runSettingsNavigator.LocalName); } @@ -100,7 +100,7 @@ public static string MakeRunsettingsCompatible(string runsettingsXml) // Delete all invalid RunConfiguration Settings if (listOfInValidRunConfigurationSettings.Count > 0) { - if(EqtTrace.IsWarningEnabled) + if (EqtTrace.IsWarningEnabled) { string settingsName = string.Join(", ", listOfInValidRunConfigurationSettings); EqtTrace.Warning(string.Format("InferRunSettingsHelper.MakeRunsettingsCompatible: Removing the following settings: {0} from RunSettings file. To use those settings please move to latest version of Microsoft.NET.Test.Sdk", settingsName)); @@ -109,7 +109,7 @@ public static string MakeRunsettingsCompatible(string runsettingsXml) // move navigator to RunConfiguration node runSettingsNavigator.MoveToParent(); - foreach(var s in listOfInValidRunConfigurationSettings) + foreach (var s in listOfInValidRunConfigurationSettings) { var nodePath = RunConfigurationNodePath + "/" + s; XmlUtilities.RemoveChildNode(runSettingsNavigator, nodePath, s); @@ -129,12 +129,14 @@ public static string MakeRunsettingsCompatible(string runsettingsXml) /// /// Updates the run settings XML with the specified values. /// - /// The navigator of the XML. + /// The XmlDocument of the XML. /// The architecture. /// The framework. /// The results directory. - public static void UpdateRunSettingsWithUserProvidedSwitches(XPathNavigator runSettingsNavigator, Architecture architecture, Framework framework, string resultsDirectory) + public static void UpdateRunSettingsWithUserProvidedSwitches(XmlDocument runSettingsDocument, Architecture architecture, Framework framework, string resultsDirectory) { + var runSettingsNavigator = runSettingsDocument.CreateNavigator(); + ValidateRunConfiguration(runSettingsNavigator); // when runsettings specifies platform, that takes precedence over the user specified platform via command line arguments. @@ -164,67 +166,65 @@ public static void UpdateRunSettingsWithUserProvidedSwitches(XPathNavigator runS VerifyCompatibilityWithOSArchitecture(architecture); // Check if inputRunSettings has results directory configured. - var hasResultsDirectory = runSettingsNavigator.SelectSingleNode(ResultsDirectoryNodePath) != null; + var hasResultsDirectory = runSettingsDocument.SelectSingleNode(ResultsDirectoryNodePath) != null; // Regenerate the effective settings. if (shouldUpdatePlatform || shouldUpdateFramework || !hasResultsDirectory) { - UpdateRunConfiguration(runSettingsNavigator, architecture, framework, resultsDirectory); + UpdateRunConfiguration(runSettingsDocument, architecture, framework, resultsDirectory); } - - runSettingsNavigator.MoveToRoot(); } /// /// Updates the RunConfiguration.DesignMode value for a run settings. Doesn't do anything if the value is already set. /// - /// Navigator for runsettings xml + /// Document for runsettings xml /// Value to set - public static void UpdateDesignMode(XPathNavigator runSettingsNavigator, bool designModeValue) + public static void UpdateDesignMode(XmlDocument runSettingsDocument, bool designModeValue) { - AddNodeIfNotPresent(runSettingsNavigator, DesignModeNodePath, DesignModeNodeName, designModeValue); + AddNodeIfNotPresent(runSettingsDocument, DesignModeNodePath, DesignModeNodeName, designModeValue); } /// /// Updates the RunConfiguration.CollectSourceInformation value for a run settings. Doesn't do anything if the value is already set. /// - /// Navigator for runsettings xml + /// Navigator for runsettings xml /// Value to set - public static void UpdateCollectSourceInformation(XPathNavigator runSettingsNavigator, bool collectSourceInformationValue) + public static void UpdateCollectSourceInformation(XmlDocument runSettingsDocument, bool collectSourceInformationValue) { - AddNodeIfNotPresent(runSettingsNavigator, CollectSourceInformationNodePath, CollectSourceInformationNodeName, collectSourceInformationValue); + AddNodeIfNotPresent(runSettingsDocument, CollectSourceInformationNodePath, CollectSourceInformationNodeName, collectSourceInformationValue); } /// /// Updates the RunConfiguration.TargetDevice value for a run settings. Doesn't do anything if the value is already set. /// - /// Navigator for runsettings xml + /// XmlDocument for runsettings xml /// Value to set - public static void UpdateTargetDevice(XPathNavigator runSettingsNavigator, string targetDevice) + public static void UpdateTargetDevice(XmlDocument runSettingsDocument, string targetDevice) { - AddNodeIfNotPresent(runSettingsNavigator, TargetDeviceNodePath, TargetDevice, targetDevice); + AddNodeIfNotPresent(runSettingsDocument, TargetDeviceNodePath, TargetDevice, targetDevice); } /// /// Updates the RunConfiguration.TargetFrameworkVersion value for a run settings. if the value is already set, behavior depends on overwrite. /// - /// Navigator for runsettings xml + /// XmlDocument for runsettings xml /// Value to set /// Overwrite option. - public static void UpdateTargetFramework(XPathNavigator runSettingsNavigator, string framework, bool overwrite=false) + public static void UpdateTargetFramework(XmlDocument runSettingsDocument, string framework, bool overwrite = false) { - AddNodeIfNotPresent(runSettingsNavigator, TargetFrameworkNodePath, TargetFrameworkNodeName, framework, overwrite); + AddNodeIfNotPresent(runSettingsDocument, TargetFrameworkNodePath, TargetFrameworkNodeName, framework, overwrite); } /// /// Updates the RunConfiguration.TargetPlatform value for a run settings. if the value is already set, behavior depends on overwrite. /// - /// Navigator for runsettings xml + /// Navigator for runsettings xml /// Value to set /// Overwrite option. - public static void UpdateTargetPlatform(XPathNavigator runSettingsNavigator, string platform, bool overwrite = false) + public static void UpdateTargetPlatform(XmlDocument runSettingsDocument, string platform, bool overwrite = false) { - AddNodeIfNotPresent(runSettingsNavigator, TargetPlatformNodePath, TargetPlatformNodeName, platform, overwrite); + AddNodeIfNotPresent(runSettingsDocument, TargetPlatformNodePath, TargetPlatformNodeName, platform, overwrite); } public static bool TryGetDeviceXml(XPathNavigator runSettingsNavigator, out String deviceXml) @@ -267,7 +267,7 @@ public static bool IsTestSettingsEnabled(string runsettingsXml) } var node = runSettingsNavigator.SelectSingleNode(@"/RunSettings/MSTest/SettingsFile"); - if(node != null && !string.IsNullOrEmpty(node.InnerXml)) + if (node != null && !string.IsNullOrEmpty(node.InnerXml)) { return true; } @@ -280,21 +280,21 @@ public static bool IsTestSettingsEnabled(string runsettingsXml) /// /// Adds node under RunConfiguration setting. Noop if node is already present. /// - private static void AddNodeIfNotPresent(XPathNavigator runSettingsNavigator, string nodePath, string nodeName, T nodeValue, bool overwrite = false) + private static void AddNodeIfNotPresent(XmlDocument xmlDocument, string nodePath, string nodeName, T nodeValue, bool overwrite = false) { // Navigator should be at Root of runsettings xml, attempt to move to /RunSettings/RunConfiguration - if (!runSettingsNavigator.MoveToChild(RunSettingsNodeName, string.Empty) || - !runSettingsNavigator.MoveToChild(RunConfigurationNodeName, string.Empty)) + var root = xmlDocument.DocumentElement; + + if (root.SelectSingleNode(RunConfigurationNodePath) == null) { - EqtTrace.Error("InferRunSettingsHelper.UpdateNodeIfNotPresent: Unable to navigate to RunConfiguration. Current node: " + runSettingsNavigator.LocalName); + EqtTrace.Error("InferRunSettingsHelper.UpdateNodeIfNotPresent: Unable to navigate to RunConfiguration. Current node: " + xmlDocument.LocalName); return; } - var node = runSettingsNavigator.SelectSingleNode(nodePath); + var node = xmlDocument.SelectSingleNode(nodePath); if (node == null || overwrite) { - XmlUtilities.AppendOrModifyChild(runSettingsNavigator, nodePath, nodeName, nodeValue.ToString()); - runSettingsNavigator.MoveToRoot(); + XmlUtilities.AppendOrModifyChild(xmlDocument, nodePath, nodeName, nodeValue.ToString()); } } @@ -370,26 +370,22 @@ private static void VerifyCompatibilityWithOSArchitecture(Architecture architect /// Regenerates the RunConfiguration node with new values under runsettings. /// private static void UpdateRunConfiguration( - XPathNavigator navigator, + XmlDocument xmlDocument, Architecture effectivePlatform, Framework effectiveFramework, string resultsDirectory) { - var resultsDirectoryNavigator = navigator.SelectSingleNode(ResultsDirectoryNodePath); + var resultsDirectoryNavigator = xmlDocument.SelectSingleNode(ResultsDirectoryNodePath); if (null != resultsDirectoryNavigator) { resultsDirectory = resultsDirectoryNavigator.InnerXml; } - XmlUtilities.AppendOrModifyChild(navigator, RunConfigurationNodePath, RunConfigurationNodeName, null); - navigator.MoveToChild(RunConfigurationNodeName, string.Empty); - - XmlUtilities.AppendOrModifyChild(navigator, ResultsDirectoryNodePath, ResultsDirectoryNodeName, resultsDirectory); - - XmlUtilities.AppendOrModifyChild(navigator, TargetPlatformNodePath, TargetPlatformNodeName, effectivePlatform.ToString()); - XmlUtilities.AppendOrModifyChild(navigator, TargetFrameworkNodePath, TargetFrameworkNodeName, effectiveFramework.ToString()); + XmlUtilities.AppendOrModifyChild(xmlDocument, RunConfigurationNodePath, RunConfigurationNodeName, null); + XmlUtilities.AppendOrModifyChild(xmlDocument, ResultsDirectoryNodePath, ResultsDirectoryNodeName, resultsDirectory); - navigator.MoveToRoot(); + XmlUtilities.AppendOrModifyChild(xmlDocument, TargetPlatformNodePath, TargetPlatformNodeName, effectivePlatform.ToString()); + XmlUtilities.AppendOrModifyChild(xmlDocument, TargetFrameworkNodePath, TargetFrameworkNodeName, effectiveFramework.ToString()); } public static bool TryGetPlatformXml(XPathNavigator runSettingsNavigator, out string platformXml) diff --git a/src/Microsoft.TestPlatform.Utilities/XmlUtilities.cs b/src/Microsoft.TestPlatform.Utilities/XmlUtilities.cs index 823f311072..5e2b5c9cc9 100644 --- a/src/Microsoft.TestPlatform.Utilities/XmlUtilities.cs +++ b/src/Microsoft.TestPlatform.Utilities/XmlUtilities.cs @@ -51,12 +51,12 @@ internal static bool IsValidNodeXmlValue(string xmlNodeValue, Func [SuppressMessage("Microsoft.Security.Xml", "CA3053:UseXmlSecureResolver", Justification = "XmlDocument.XmlResolver is not available in core. Suppress until fxcop issue is fixed.")] internal static void AppendOrModifyChild( - XPathNavigator parentNavigator, + XmlDocument xmlDocument, string nodeXPath, string nodeName, string innerXml) { - var childNodeNavigator = parentNavigator.SelectSingleNode(nodeXPath); + var childNodeNavigator = xmlDocument.SelectSingleNode(nodeXPath); // Todo: There isn't an equivalent API to SecurityElement.Escape in Core yet. // So trusting that the XML is always valid for now. @@ -67,35 +67,19 @@ internal static void AppendOrModifyChild( #endif if (childNodeNavigator == null) { - var doc = new XmlDocument(); - var childElement = doc.CreateElement(nodeName); + var childElement = xmlDocument.CreateElement(nodeName); if (!string.IsNullOrEmpty(innerXml)) { childElement.InnerXml = secureInnerXml; } - childNodeNavigator = childElement.CreateNavigator(); - parentNavigator.AppendChild(childNodeNavigator); + var parentNode = xmlDocument.SelectSingleNode(nodeXPath.Substring(0, nodeXPath.LastIndexOf('/'))); + parentNode.AppendChild(childElement); } else if (!string.IsNullOrEmpty(innerXml)) { -#if NET451 childNodeNavigator.InnerXml = secureInnerXml; -#else - // .Net Core has a bug where calling childNodeNavigator.InnerXml throws an XmlException with "Data at the root level is invalid". - // So doing the below instead. - var doc = new XmlDocument(); - - var childElement = doc.CreateElement(nodeName); - - if (!string.IsNullOrEmpty(innerXml)) - { - childElement.InnerXml = secureInnerXml; - } - - childNodeNavigator.ReplaceSelf(childElement.CreateNavigator().OuterXml); -#endif } } diff --git a/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs b/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs index 60ca7328ad..5e74ddbc63 100644 --- a/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs +++ b/src/vstest.console/Processors/EnableCodeCoverageArgumentProcessor.cs @@ -160,11 +160,7 @@ private void UpdateWithCodeCoverageSettingsIfNotConfigured() { var document = new XmlDocument(); document.Load(reader); -#if NET451 runSettingsDocument = document; -#else - runSettingsDocument = document.ToXPathNavigable(); -#endif } var runSettingsNavigator = runSettingsDocument.CreateNavigator(); diff --git a/src/vstest.console/Processors/RunSettingsArgumentProcessor.cs b/src/vstest.console/Processors/RunSettingsArgumentProcessor.cs index 9098f2dc20..308ef965a7 100644 --- a/src/vstest.console/Processors/RunSettingsArgumentProcessor.cs +++ b/src/vstest.console/Processors/RunSettingsArgumentProcessor.cs @@ -182,11 +182,7 @@ private IXPathNavigable GetRunSettingsDocument(string runSettingsFile) var settingsDocument = new XmlDocument(); settingsDocument.Load(reader); ClientUtilities.FixRelativePathsInRunSettings(settingsDocument, runSettingsFile); -#if NET451 runSettingsDocument = settingsDocument; -#else - runSettingsDocument = settingsDocument.ToXPathNavigable(); -#endif } } else diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 0bb64d72ec..8c73862869 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -410,14 +410,14 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou if (updateFramework) { - InferRunSettingsHelper.UpdateTargetFramework(navigator, inferedFramework?.ToString(), overwrite: true); + InferRunSettingsHelper.UpdateTargetFramework(document, inferedFramework?.ToString(), overwrite: true); chosenFramework = inferedFramework; settingsUpdated = true; } if (updatePlatform) { - InferRunSettingsHelper.UpdateTargetPlatform(navigator, inferedPlatform.ToString(), overwrite: true); + InferRunSettingsHelper.UpdateTargetPlatform(document, inferedPlatform.ToString(), overwrite: true); chosenPlatform = inferedPlatform; settingsUpdated = true; } @@ -441,19 +441,19 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou if (!runConfiguration.DesignModeSet) { - InferRunSettingsHelper.UpdateDesignMode(navigator, this.commandLineOptions.IsDesignMode); + InferRunSettingsHelper.UpdateDesignMode(document, this.commandLineOptions.IsDesignMode); settingsUpdated = true; } if (!runConfiguration.CollectSourceInformationSet) { - InferRunSettingsHelper.UpdateCollectSourceInformation(navigator, this.commandLineOptions.ShouldCollectSourceInformation); + InferRunSettingsHelper.UpdateCollectSourceInformation(document, this.commandLineOptions.ShouldCollectSourceInformation); settingsUpdated = true; } if (InferRunSettingsHelper.TryGetDeviceXml(navigator, out string deviceXml)) { - InferRunSettingsHelper.UpdateTargetDevice(navigator, deviceXml); + InferRunSettingsHelper.UpdateTargetDevice(document, deviceXml); settingsUpdated = true; } diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs index b3206616e4..b8fab24f6a 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs @@ -40,9 +40,9 @@ public InferRunSettingsHelperTests() public void UpdateRunSettingsShouldThrowIfRunSettingsNodeDoesNotExist() { var settings = @""; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X86, Framework.DefaultFramework, "temp"); + Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); Assert.That.Throws(action) .WithMessage(string.Format("An error occurred while loading the settings. Error: {0}.", @@ -53,9 +53,9 @@ public void UpdateRunSettingsShouldThrowIfRunSettingsNodeDoesNotExist() public void UpdateRunSettingsShouldThrowIfPlatformNodeIsInvalid() { var settings = @"foo"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X86, Framework.DefaultFramework, "temp"); + Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); Assert.That.Throws(action) .WithMessage(string.Format("An error occurred while loading the settings. Error: {0}.", @@ -69,9 +69,9 @@ public void UpdateRunSettingsShouldThrowIfPlatformNodeIsInvalid() public void UpdateRunSettingsShouldThrowIfFrameworkNodeIsInvalid() { var settings = @"foo"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X86, Framework.DefaultFramework, "temp"); + Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); Assert.That.Throws(action) .WithMessage(string.Format("An error occurred while loading the settings. Error: {0}.", @@ -85,11 +85,11 @@ public void UpdateRunSettingsShouldThrowIfFrameworkNodeIsInvalid() public void UpdateRunSettingsShouldUpdateWithPlatformSettings() { var settings = @""; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X86, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); - var xml = navigator.OuterXml; + var xml = xmlDocument.OuterXml; StringAssert.Contains(xml, "X86"); } @@ -98,11 +98,11 @@ public void UpdateRunSettingsShouldUpdateWithPlatformSettings() public void UpdateRunSettingsShouldUpdateWithFrameworkSettings() { var settings = @""; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X86, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); - var xml = navigator.OuterXml; + var xml = xmlDocument.OuterXml; StringAssert.Contains(xml, $"{Framework.DefaultFramework.Name}"); } @@ -111,11 +111,11 @@ public void UpdateRunSettingsShouldUpdateWithFrameworkSettings() public void UpdateRunSettingsShouldUpdateWithResultsDirectorySettings() { var settings = @""; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X86, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp"); - var xml = navigator.OuterXml; + var xml = xmlDocument.OuterXml; StringAssert.Contains(xml, "temp"); } @@ -124,11 +124,11 @@ public void UpdateRunSettingsShouldUpdateWithResultsDirectorySettings() public void UpdateRunSettingsShouldNotUpdatePlatformIfRunSettingsAlreadyHasIt() { var settings = @"X86"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - var xml = navigator.OuterXml; + var xml = xmlDocument.OuterXml; StringAssert.Contains(xml, "X86"); } @@ -137,11 +137,11 @@ public void UpdateRunSettingsShouldNotUpdatePlatformIfRunSettingsAlreadyHasIt() public void UpdateRunSettingsShouldNotUpdateFrameworkIfRunSettingsAlreadyHasIt() { var settings = @"Framework40"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - var xml = navigator.OuterXml; + var xml = xmlDocument.OuterXml; StringAssert.Contains(xml, ".NETFramework,Version=v4.0"); } @@ -152,11 +152,11 @@ public void UpdateRunSettingsShouldAllowTargetFrameworkMonikerValue() { var settings = @".NETFramework,Version=v4.0"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - var xml = navigator.OuterXml; + var xml = xmlDocument.OuterXml; StringAssert.Contains(xml, ".NETFramework,Version=v4.0"); } @@ -165,11 +165,11 @@ public void UpdateRunSettingsShouldAllowTargetFrameworkMonikerValue() public void UpdateRunSettingsShouldNotUpdateResultsDirectoryIfRunSettingsAlreadyHasIt() { var settings = @"someplace"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - var xml = navigator.OuterXml; + var xml = xmlDocument.OuterXml; StringAssert.Contains(xml, "someplace"); } @@ -178,11 +178,11 @@ public void UpdateRunSettingsShouldNotUpdateResultsDirectoryIfRunSettingsAlready public void UpdateRunSettingsShouldNotUpdatePlatformOrFrameworkOrResultsDirectoryIfRunSettingsAlreadyHasIt() { var settings = @"X86Framework40someplace"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - var xml = navigator.OuterXml; + var xml = xmlDocument.OuterXml; StringAssert.Contains(xml, "X86"); StringAssert.Contains(xml, "Framework40"); @@ -193,11 +193,11 @@ public void UpdateRunSettingsShouldNotUpdatePlatformOrFrameworkOrResultsDirector public void UpdateRunSettingsWithAnEmptyRunSettingsShouldAddValuesSpecifiedInRunConfiguration() { var settings = @""; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - var xml = navigator.OuterXml; + var xml = xmlDocument.OuterXml; StringAssert.Contains(xml, "X64"); StringAssert.Contains(xml, $"{Framework.DefaultFramework.Name}"); @@ -208,12 +208,12 @@ public void UpdateRunSettingsWithAnEmptyRunSettingsShouldAddValuesSpecifiedInRun public void UpdateRunSettingsShouldReturnBackACompleteRunSettings() { var settings = @""; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.X64, Framework.DefaultFramework, "temp"); + InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X64, Framework.DefaultFramework, "temp"); - var xml = navigator.OuterXml; - var expectedRunSettings = string.Format("\r\n \r\n temp\r\n X64\r\n {0}\r\n \r\n", Framework.DefaultFramework.Name); + var xml = xmlDocument.OuterXml; + var expectedRunSettings = string.Format("tempX64{0}", Framework.DefaultFramework.Name); Assert.AreEqual(expectedRunSettings, xml); } @@ -222,9 +222,9 @@ public void UpdateRunSettingsShouldReturnBackACompleteRunSettings() public void UpdateRunSettingsShouldThrowIfArchitectureSetIsIncompatibleWithCurrentSystemArchitecture() { var settings = @""; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(navigator, Architecture.ARM, Framework.DefaultFramework, "temp"); + Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.ARM, Framework.DefaultFramework, "temp"); Assert.That.Throws(action) .WithMessage(string.Format( @@ -233,41 +233,17 @@ public void UpdateRunSettingsShouldThrowIfArchitectureSetIsIncompatibleWithCurre XmlRunSettingsUtilities.OSArchitecture.ToString())); } - [DataTestMethod] - [DataRow("DesignMode")] - [DataRow("CollectSourceInformation")] - public void UpdateRunSettingsShouldNotModifyXmlIfNavigatorIsNotAtRootNode(string settingName) - { - var settings = @""; - var navigator = this.GetNavigator(settings); - navigator.MoveToFirstChild(); - - switch (settingName.ToUpperInvariant()) - { - case "DESIGNMODE": - InferRunSettingsHelper.UpdateDesignMode(navigator, true); - break; - - case "COLLECTSOURCEINFORMATION": - InferRunSettingsHelper.UpdateCollectSourceInformation(navigator, true); - break; - }; - - navigator.MoveToRoot(); - Assert.IsTrue(navigator.InnerXml.IndexOf(settingName, StringComparison.OrdinalIgnoreCase) < 0); - } - [TestMethod] public void UpdateDesignModeOrCsiShouldNotModifyXmlIfNodeIsAlreadyPresent() { var settings = @"FalseFalse"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateDesignMode(navigator, true); - InferRunSettingsHelper.UpdateCollectSourceInformation(navigator, true); + InferRunSettingsHelper.UpdateDesignMode(xmlDocument, true); + InferRunSettingsHelper.UpdateCollectSourceInformation(xmlDocument, true); - Assert.AreEqual("False", this.GetValueOf(navigator, "/RunSettings/RunConfiguration/DesignMode")); - Assert.AreEqual("False", this.GetValueOf(navigator, "/RunSettings/RunConfiguration/CollectSourceInformation")); + Assert.AreEqual("False", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/DesignMode")); + Assert.AreEqual("False", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/CollectSourceInformation")); } [DataTestMethod] @@ -276,13 +252,13 @@ public void UpdateDesignModeOrCsiShouldNotModifyXmlIfNodeIsAlreadyPresent() public void UpdateDesignModeOrCsiShouldModifyXmlToValueProvided(bool val) { var settings = @""; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateDesignMode(navigator, val); - InferRunSettingsHelper.UpdateCollectSourceInformation(navigator, val); + InferRunSettingsHelper.UpdateDesignMode(xmlDocument, val); + InferRunSettingsHelper.UpdateCollectSourceInformation(xmlDocument, val); - Assert.AreEqual(val.ToString(), this.GetValueOf(navigator, "/RunSettings/RunConfiguration/DesignMode")); - Assert.AreEqual(val.ToString(), this.GetValueOf(navigator, "/RunSettings/RunConfiguration/CollectSourceInformation")); + Assert.AreEqual(val.ToString(), this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/DesignMode")); + Assert.AreEqual(val.ToString(), this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/CollectSourceInformation")); } [TestMethod] @@ -339,79 +315,79 @@ public void UpdateTargetDeviceValueFromOldMsTestSettings() "; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - var result = InferRunSettingsHelper.TryGetDeviceXml(navigator, out string deviceXml); + var result = InferRunSettingsHelper.TryGetDeviceXml(xmlDocument.CreateNavigator(), out string deviceXml); Assert.IsTrue(result); - InferRunSettingsHelper.UpdateTargetDevice(navigator, deviceXml); - Assert.AreEqual(deviceXml.ToString(), this.GetValueOf(navigator, "/RunSettings/RunConfiguration/TargetDevice")); + InferRunSettingsHelper.UpdateTargetDevice(xmlDocument, deviceXml); + Assert.AreEqual(deviceXml.ToString(), this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetDevice")); } [TestMethod] public void UpdateTargetPlatformShouldNotModifyXmlIfNodeIsAlreadyPresentForOverwriteFalse() { var settings = @"x86"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetPlatform(navigator, "X64", overwrite: false); + InferRunSettingsHelper.UpdateTargetPlatform(xmlDocument, "X64", overwrite: false); - Assert.AreEqual("x86", this.GetValueOf(navigator, "/RunSettings/RunConfiguration/TargetPlatform")); + Assert.AreEqual("x86", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetPlatform")); } [TestMethod] public void UpdateTargetPlatformShouldModifyXmlIfNodeIsAlreadyPresentForOverwriteTrue() { var settings = @"x86"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetPlatform(navigator, "X64", overwrite: true); + InferRunSettingsHelper.UpdateTargetPlatform(xmlDocument, "X64", overwrite: true); - Assert.AreEqual("X64", this.GetValueOf(navigator, "/RunSettings/RunConfiguration/TargetPlatform")); + Assert.AreEqual("X64", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetPlatform")); } [TestMethod] public void UpdateTargetPlatformShouldAddPlatformXmlNodeIfNotPresent() { var settings = @""; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetPlatform(navigator, "X64"); + InferRunSettingsHelper.UpdateTargetPlatform(xmlDocument, "X64"); - Assert.AreEqual("X64", this.GetValueOf(navigator, "/RunSettings/RunConfiguration/TargetPlatform")); + Assert.AreEqual("X64", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetPlatform")); } [TestMethod] public void UpdateTargetFrameworkShouldNotModifyXmlIfNodeIsAlreadyPresentForOverwriteFalse() { var settings = @".NETFramework,Version=v4.5"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetFramework(navigator, ".NETCoreApp,Version=v1.0", overwrite: false); + InferRunSettingsHelper.UpdateTargetFramework(xmlDocument, ".NETCoreApp,Version=v1.0", overwrite: false); - Assert.AreEqual(".NETFramework,Version=v4.5", this.GetValueOf(navigator, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); + Assert.AreEqual(".NETFramework,Version=v4.5", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); } [TestMethod] public void UpdateTargetFrameworkShouldModifyXmlIfNodeIsAlreadyPresentForOverwriteTrue() { var settings = @".NETFramework,Version=v4.5"; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetFramework(navigator, ".NETCoreApp,Version=v1.0", overwrite: true); + InferRunSettingsHelper.UpdateTargetFramework(xmlDocument, ".NETCoreApp,Version=v1.0", overwrite: true); - Assert.AreEqual(".NETCoreApp,Version=v1.0", this.GetValueOf(navigator, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); + Assert.AreEqual(".NETCoreApp,Version=v1.0", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); } [TestMethod] public void UpdateTargetFrameworkShouldAddFrameworkXmlNodeIfNotPresent() { var settings = @""; - var navigator = this.GetNavigator(settings); + var xmlDocument = this.GetXmlDocument(settings); - InferRunSettingsHelper.UpdateTargetFramework(navigator, ".NETCoreApp,Version=v1.0"); + InferRunSettingsHelper.UpdateTargetFramework(xmlDocument, ".NETCoreApp,Version=v1.0"); - Assert.AreEqual(".NETCoreApp,Version=v1.0", this.GetValueOf(navigator, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); + Assert.AreEqual(".NETCoreApp,Version=v1.0", this.GetValueOf(xmlDocument, "/RunSettings/RunConfiguration/TargetFrameworkVersion")); } [TestMethod] @@ -524,18 +500,17 @@ private string GetSourceIncompatibleMessage(string source) return string.Format(CultureInfo.CurrentCulture, OMResources.SourceIncompatible, source, sourceFrameworks[source].Version, sourceArchitectures[source]); } - private XPathNavigator GetNavigator(string settingsXml) + private XmlDocument GetXmlDocument(string settingsXml) { var doc = new XmlDocument(); doc.LoadXml(settingsXml); - return doc.CreateNavigator(); + return doc; } - private string GetValueOf(XPathNavigator navigator, string xpath) + private string GetValueOf(XmlDocument xmlDocument, string xpath) { - navigator.MoveToRoot(); - return navigator.SelectSingleNode(xpath).Value; + return xmlDocument.SelectSingleNode(xpath).InnerText; } #endregion } diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/XmlUtilitiesTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/XmlUtilitiesTests.cs index b35d1a4fbd..5c99e77d20 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/XmlUtilitiesTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/XmlUtilitiesTests.cs @@ -17,7 +17,7 @@ public class XmlUtilitiesTests #region GetNodeXml tests [TestMethod] - public void GetNodeXmlShouldThrowIfNavigatorIsNull() + public void GetNodeXmlShouldThrowIfxmlDocumentIsNull() { Assert.ThrowsException(() => XmlUtilities.GetNodeXml(null, @"/RunSettings/RunConfiguration")); } @@ -26,36 +26,36 @@ public void GetNodeXmlShouldThrowIfNavigatorIsNull() public void GetNodeXmlShouldThrowIfXPathIsNull() { var settingsXml = @""; - var navigator = this.GetNavigator(settingsXml); + var xmlDocument = this.GetXmlDocument(settingsXml); - Assert.ThrowsException(() => XmlUtilities.GetNodeXml(navigator, null)); + Assert.ThrowsException(() => XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), null)); } [TestMethod] public void GetNodeXmlShouldThrowIfXPathIsInvalid() { var settingsXml = @""; - var navigator = this.GetNavigator(settingsXml); + var xmlDocument = this.GetXmlDocument(settingsXml); - Assert.ThrowsException(() => XmlUtilities.GetNodeXml(navigator, @"Rs\r")); + Assert.ThrowsException(() => XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), @"Rs\r")); } [TestMethod] public void GetNodeXmlShouldReturnNullIfNodeDoesNotExist() { var settingsXml = @""; - var navigator = this.GetNavigator(settingsXml); + var xmlDocument = this.GetXmlDocument(settingsXml); - Assert.IsNull(XmlUtilities.GetNodeXml(navigator, @"/RunSettings/RunConfiguration")); + Assert.IsNull(XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), @"/RunSettings/RunConfiguration")); } [TestMethod] public void GetNodeXmlShouldReturnNodeValue() { var settingsXml = @"abc"; - var navigator = this.GetNavigator(settingsXml); + var xmlDocument = this.GetXmlDocument(settingsXml); - Assert.AreEqual("abc", XmlUtilities.GetNodeXml(navigator, @"/RunSettings/RC")); + Assert.AreEqual("abc", XmlUtilities.GetNodeXml(xmlDocument.CreateNavigator(), @"/RunSettings/RC")); } #endregion @@ -99,65 +99,57 @@ public void IsValidNodeXmlValueShouldReturnTrueIfValidatorReturnsTrue() #endregion #region AppendOrModifyChild tests - + [TestMethod] public void AppendOrModifyChildShouldModifyExistingNode() { var settingsXml = @"abc"; - var navigator = this.GetNavigator(settingsXml); - - navigator.MoveToChild("RunSettings", string.Empty); + var xmlDocument = this.GetXmlDocument(settingsXml); - XmlUtilities.AppendOrModifyChild(navigator, @"/RunSettings/RC", "RC", "ab"); + XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", "ab"); - var rcNavigator = navigator.SelectSingleNode(@"/RunSettings/RC"); - Assert.IsNotNull(rcNavigator); - Assert.AreEqual("ab", rcNavigator.InnerXml); + var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); + Assert.IsNotNull(rcxmlDocument); + Assert.AreEqual("ab", rcxmlDocument.InnerXml); } [TestMethod] public void AppendOrModifyChildShouldAppendANewNode() { var settingsXml = @""; - var navigator = this.GetNavigator(settingsXml); + var xmlDocument = this.GetXmlDocument(settingsXml); - navigator.MoveToChild("RunSettings", string.Empty); + XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", "abc"); - XmlUtilities.AppendOrModifyChild(navigator, @"/RunSettings/RC", "RC", "abc"); - - var rcNavigator = navigator.SelectSingleNode(@"/RunSettings/RC"); - Assert.IsNotNull(rcNavigator); - Assert.AreEqual("abc", rcNavigator.InnerXml); + var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); + Assert.IsNotNull(rcxmlDocument); + Assert.AreEqual("abc", rcxmlDocument.InnerXml); } [TestMethod] public void AppendOrModifyChildShouldNotModifyExistingXmlIfInnerXmlPassedInIsNull() { var settingsXml = @"abc"; - var navigator = this.GetNavigator(settingsXml); - - navigator.MoveToChild("RunSettings", string.Empty); + var xmlDocument = this.GetXmlDocument(settingsXml); - XmlUtilities.AppendOrModifyChild(navigator, @"/RunSettings/RC", "RC", null); + XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", null); - var rcNavigator = navigator.SelectSingleNode(@"/RunSettings/RC"); - Assert.IsNotNull(rcNavigator); - Assert.AreEqual("abc", rcNavigator.InnerXml); + var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); + Assert.IsNotNull(rcxmlDocument); + Assert.AreEqual("abc", rcxmlDocument.InnerXml); } [TestMethod] public void AppendOrModifyChildShouldCreateAnEmptyNewNodeIfInnerXmlPassedInIsNull() { var settingsXml = @""; - var navigator = this.GetNavigator(settingsXml); + var xmlDocument = this.GetXmlDocument(settingsXml); - navigator.MoveToChild("RunSettings", string.Empty); - - XmlUtilities.AppendOrModifyChild(navigator, @"/RunSettings/RC", "RC", null); + XmlUtilities.AppendOrModifyChild(xmlDocument, @"/RunSettings/RC", "RC", null); - var rcNavigator = navigator.SelectSingleNode(@"/RunSettings/RC"); - Assert.IsNotNull(rcNavigator); - Assert.AreEqual(string.Empty, rcNavigator.InnerXml); + var rcxmlDocument = xmlDocument.SelectSingleNode(@"/RunSettings/RC"); + Assert.IsNotNull(rcxmlDocument); + Assert.AreEqual(string.Empty, rcxmlDocument.InnerXml); } #endregion @@ -168,38 +160,35 @@ public void AppendOrModifyChildShouldCreateAnEmptyNewNodeIfInnerXmlPassedInIsNul public void RemoveChildNodeShouldNotModifyExistingXmlIfNodeDoesnotExist() { var settingsXml = @""; - var navigator = this.GetNavigator(settingsXml); + var xmlDocument = this.GetXmlDocument(settingsXml); - navigator.MoveToChild("RunSettings", string.Empty); + XmlUtilities.RemoveChildNode(xmlDocument.CreateNavigator(), @"/RunSettings/RC", "RC"); - XmlUtilities.RemoveChildNode(navigator, @"/RunSettings/RC", "RC"); - - Assert.AreEqual(settingsXml, navigator.OuterXml); + Assert.AreEqual(settingsXml, xmlDocument.OuterXml); } [TestMethod] public void RemoveChildNodeShouldRemoveXmlIfExist() { var settingsXml = @"abc"; - var navigator = this.GetNavigator(settingsXml); - + var xmlDocument = this.GetXmlDocument(settingsXml); + var navigator = xmlDocument.CreateNavigator(); navigator.MoveToChild("RunSettings", string.Empty); - XmlUtilities.RemoveChildNode(navigator, @"/RunSettings/RC", "RC"); - Assert.AreEqual(@"", navigator.OuterXml); + Assert.AreEqual(@"", xmlDocument.OuterXml); } #endregion #region private methods - private XPathNavigator GetNavigator(string settingsXml) + private XmlDocument GetXmlDocument(string settingsXml) { var doc = new XmlDocument(); doc.LoadXml(settingsXml); - return doc.CreateNavigator(); + return doc; } #endregion diff --git a/test/vstest.console.UnitTests/Processors/EnableCodeCoverageArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/EnableCodeCoverageArgumentProcessorTests.cs index 6ed024421e..bdf731c510 100644 --- a/test/vstest.console.UnitTests/Processors/EnableCodeCoverageArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/EnableCodeCoverageArgumentProcessorTests.cs @@ -73,7 +73,6 @@ public void InitializeShouldSetEnableCodeCoverageOfCommandLineOption() } [TestMethod] - [Ignore("Data Collectors not working with dotnet vstest/dotnet test Issue: https://devdiv.visualstudio.com/DevDiv/VS.in%20Agile%20Testing%20IDE/_queries/edit/491724/?triage=true")] public void InitializeShouldCreateEntryForCodeCoverageInRunSettingsIfNotAlreadyPresent() { var runsettingsString = string.Format(DefaultRunSettings, ""); diff --git a/test/vstest.console.UnitTests/Processors/RunSettingsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/RunSettingsArgumentProcessorTests.cs index 0be7fa5739..57753e5192 100644 --- a/test/vstest.console.UnitTests/Processors/RunSettingsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/RunSettingsArgumentProcessorTests.cs @@ -214,7 +214,6 @@ public void InitializeShouldAddDefaultSettingsIfNotPresent() } [TestMethod] - [Ignore("Data Collectors not working with dotnet vstest/dotnet test Issue: https://devdiv.visualstudio.com/DevDiv/VS.in%20Agile%20Testing%20IDE/_queries/edit/491724/?triage=true")] public void InitializeShouldSetActiveRunSettingsForTestSettingsFiles() { // Arrange. @@ -236,7 +235,7 @@ public void InitializeShouldSetActiveRunSettingsForTestSettingsFiles() // Assert. Assert.IsNotNull(this.settingsProvider.ActiveRunSettings); - StringAssert.Contains(this.settingsProvider.ActiveRunSettings.SettingsXml, $"\r\n \r\n {Constants.DefaultPlatform}\r\n {Framework.FromString(FrameworkVersion.Framework45.ToString()).Name}\r\n {Constants.DefaultResultsDirectory}\r\n \r\n \r\n C:\\temp\\r.testsettings\r\n true\r\n \r\n \r\n \r\n \r\n"); + StringAssert.Contains(this.settingsProvider.ActiveRunSettings.SettingsXml, $"\r\n\r\n \r\n {Constants.DefaultPlatform}\r\n {Framework.FromString(FrameworkVersion.Framework45.ToString()).Name}\r\n {Constants.DefaultResultsDirectory}\r\n \r\n \r\n C:\\temp\\r.testsettings\r\n true\r\n \r\n \r\n \r\n \r\n"); }