Esempio n. 1
0
        public static string QueryRunSettingsNode(this IRunSettingsProvider runSettingsProvider, string key)
        {
            ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider));
            ValidateArg.NotNullOrWhiteSpace(key, nameof(key));

            var xmlDocument = runSettingsProvider.GetRunSettingXmlDocument();
            var node        = GetXmlNode(xmlDocument, key);

            return(node?.InnerText);
        }
Esempio n. 2
0
        public static void UpdateRunSettingsNode(this IRunSettingsProvider runSettingsProvider, string key, string data)
        {
            ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider));
            ValidateArg.NotNullOrWhiteSpace(key, nameof(key));
            ValidateArg.NotNull(data, nameof(data));

            var xmlDocument = runSettingsProvider.GetRunSettingXmlDocument();

            RunSettingsProviderExtensions.UpdateRunSettingsXmlDocument(xmlDocument, key, data);
            runSettingsProvider.UpdateRunSettings(xmlDocument.OuterXml);
        }
Esempio n. 3
0
        public static void UpdateRunSettingsNodeInnerXml(this IRunSettingsProvider runSettingsProvider, string key, string xml)
        {
            ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider));
            ValidateArg.NotNullOrWhiteSpace(key, nameof(key));
            ValidateArg.NotNull(xml, nameof(xml));

            var xmlDocument = runSettingsProvider.GetRunSettingXmlDocument();

            UpdateRunSettingsXmlDocumentInnerXml(xmlDocument, key, xml);
            runSettingsProvider.UpdateRunSettings(xmlDocument.OuterXml);
        }
Esempio n. 4
0
        /// <summary>
        /// If test run parameter exists already it will override with new value otherwise this will add new test run parameter.
        /// </summary>
        /// <param name="runSettingsProvider"></param>
        /// <param name="match"></param>
        public static void UpdateTestRunParameterSettingsNode(this IRunSettingsProvider runSettingsProvider, Match match)
        {
            ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider));

            var     xmlDocument          = runSettingsProvider.GetRunSettingXmlDocument();
            XmlNode testRunParameterNode = GetXmlNode(xmlDocument, Constants.TestRunParametersName) ?? xmlDocument.CreateElement(Constants.TestRunParametersName);
            var     attrName             = match.Groups[AttributeNameString].Value;
            var     attrValue            = match.Groups[AttributeValueString].Value;

            if (!TryOverrideAttributeValue(testRunParameterNode, attrName, attrValue))
            {
                XmlElement element = xmlDocument.CreateElement(ParameterString);
                element.SetAttribute(NameString, attrName);
                element.SetAttribute(ValueString, attrValue);
                testRunParameterNode.AppendChild(element);
                xmlDocument.DocumentElement.AppendChild(testRunParameterNode);
            }

            runSettingsProvider.UpdateRunSettings(xmlDocument.OuterXml);
        }