//Parses decision tree file, which contains information about rules of configurations //recursively calls parseDTXML function static void parseDecisionTreeXML(string filename) { FileStream reader = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); XmlDocument compSpecs = new XmlDocument(); compSpecs.Load(reader); XmlNodeList nodeList = compSpecs.GetElementsByTagName("tree"); //for every tree node for (int counter = 0; counter < nodeList.Count; counter++) { XmlNode testNode = nodeList[counter]; //get test id string testId = testNode.Attributes[1].Value; //find the location of the test with that id int location = -1; for (int a = 0; a < TESTCASE_LIST.Count; a++) { if (testId == TESTCASE_LIST[a].getId()) location = a; } //if we find the testcase with that testId if (location != -1) { XmlNodeList ruleNodes = testNode.ChildNodes; for (int x = 0; x < ruleNodes.Count; x++) { List<Item> list = new List<Item>(); parseDTXML(ruleNodes[x], list, location); } //calculate covering options list //get the rule list List<Rule> ruleList = TESTCASE_LIST[location].getRuleList(); List<string> coveringList = new List<string>(); //for every rule in the list for (int x = 0; x < ruleList.Count; x++) { Rule tempRule = new Rule(); tempRule.setEqualTo(ruleList[x]); //get the item list for that rule List<Item> itemList = tempRule.getItemList(); //for every item in the rule for (int y = 0; y < itemList.Count; y++) { string optionName = itemList[y].getObjectName(); //if that option is not added to the list so far add it to the covering option list addToList(coveringList, optionName); } } TESTCASE_LIST[location].setCoveringListOptions(coveringList); } } reader.Close(); }
//returns the option list of the rule, that configuration is violating static List<Item> getRuleViolatingOptions(Configuration input, int order) { Configuration testingConfig = new Configuration(); testingConfig.setEqualTo(input); List<Item> optionsList = testingConfig.getItemList(); for (int counter = 0; counter < TESTCASE_LIST[order].getRuleList().Count; counter++) { Rule tempRule = new Rule(); tempRule.setEqualTo(TESTCASE_LIST[order].getRuleList()[counter]); List<Item> ruleOptionList = tempRule.getItemList(); bool thereIsError = true; for (int a = 0; a < ruleOptionList.Count; a++) { string optionName = ruleOptionList[a].getObjectName(); string optionValue = ruleOptionList[a].getObjectValue(); Item dummy = new Item(optionName, optionValue); if (!doesExist(optionsList, dummy)) { thereIsError = false; break; } } if (thereIsError) { List<Item> result = new List<Item>(); for (int a = 0; a < ruleOptionList.Count; a++) result.Add(ruleOptionList[a]); return result; } } return null; }
//Given a configuration, checks if this configuration passes based on the rule list static bool doesThisConfigPass(Configuration param1, int order) { Configuration testingConfig = new Configuration(); testingConfig.setEqualTo(param1); List<Item> optionsList = testingConfig.getItemList(); for (int counter = 0; counter < TESTCASE_LIST[order].getRuleList().Count; counter++) { Rule tempRule = new Rule(); tempRule.setEqualTo(TESTCASE_LIST[order].getRuleList()[counter]); List<Item> ruleOptionList = tempRule.getItemList(); bool thereIsError = true; for (int a = 0; a < ruleOptionList.Count; a++) { string optionName = ruleOptionList[a].getObjectName(); string optionValue = ruleOptionList[a].getObjectValue(); Item dummy = new Item(optionName, optionValue); if (!doesExist(optionsList, dummy)) { thereIsError = false; break; } } if (thereIsError) return false; } return true; }
public void setRuleList(List<Rule> param1) { RuleList.Clear(); for (int a = 0; a < param1.Count; a++) { Rule temp = new Rule(); temp.setEqualTo(param1[a]); RuleList.Add(temp); } }
public List<Rule> getRuleList() { List<Rule> result = new List<Rule>(); for (int a = 0; a < RuleList.Count; a++) { Rule temp = new Rule(); temp.setEqualTo(RuleList[a]); result.Add(temp); } return result; }
public void addRule(Rule param1) { Rule temp = new Rule(); temp.setEqualTo(param1); RuleList.Add(temp); }