Example #1
0
        public void EvalCustomVariables(XmlNode productCustomVars)
        {
            if (productCustomVars != null && productCustomVars.HasChildNodes)
            {
                RequirementHandlers reqHandlers = new RequirementHandlers();
                foreach (XmlNode CustomVar in productCustomVars.ChildNodes)
                {
                    ProductSettings.ProductRequirement requirement = new ProductSettings.ProductRequirement
                    {
                        Type            = XmlParser.GetStringValue(CustomVar, "Type"),
                        LogicalOperator = XmlParser.GetStringAttribute(CustomVar, "Keys", "logicalOp")
                    };
                    if (string.IsNullOrEmpty(requirement.LogicalOperator))
                    {
                        requirement.LogicalOperator = Enum.GetName(typeof(RequirementHandlers.LogicalOperatorType), RequirementHandlers.LogicalOperatorType.AND); //default value
                    }
                    requirement.Keys = new List <ProductSettings.RequirementKey>();
                    foreach (XmlNode requirementKey in CustomVar.SelectNodes("Keys/Key"))
                    {
                        ProductSettings.RequirementKey reqKey;
                        reqKey.KeyValue = XmlParser.GetStringValue(requirementKey);
                        reqKey.KeyType  = XmlParser.GetStringAttribute(requirementKey, "type");

                        requirement.Keys.Add(reqKey);
                    }
                    string newElementName = XmlParser.GetStringAttribute(CustomVar, "name");
                    if (newElementName != "")
                    {
                        XmlElement elem = xmlDoc.CreateElement(newElementName);
                        elem.InnerText = reqHandlers.EvalRequirement(requirement);
                        productCustomVars.AppendChild(elem);
                    }
                }
            }
        }
 public void TestProductCustomVariables()
 {
     foreach (XmlNode CustomVar in textDoc.SelectNodes("//Products/Product/CustomData/CustomVars"))
     {
         Assert.AreNotEqual(CustomVar.SelectSingleNode("//winVer").InnerText, "", "No custom variable winVer");
         Assert.AreEqual(CustomVar.SelectSingleNode("//winVerExists").InnerText, "true", "No custom variable winVerExists");
         Assert.AreNotEqual(CustomVar.SelectSingleNode("//totalRam").InnerText, "", "No custom variable totalRam");
         Assert.AreEqual(CustomVar.SelectSingleNode("//ChromeNotInstalled").InnerText, "false", "No custom variable ChromeNotInstalled");
         Assert.AreEqual(CustomVar.SelectSingleNode("//AreFilesExists").InnerText, "true", "No custom variable AreFilesExists");
         Assert.AreNotEqual(CustomVar.SelectSingleNode("//CheckConfigValue").InnerText, "", "No custom variable CheckConfigValue");
     }
 }