Exemple #1
0
        //if the node is a "test" node, that means rule consists of more Item objects. so keep on parsing
        //if the node is a "output" node, that means parsing of rule options is complete. get the result and get out.
        static void parseDTXML(XmlNode node, List<Item> itemList, int order)
        {
            if (node.Name == "test")
            {
                XmlAttributeCollection attrList = node.Attributes;
                string attribute = attrList[0].Value;
                string value = attrList[2].Value;

                Item temp = new Item(attribute, value);
                itemList.Add(temp);

                for (int a = 0; a < node.ChildNodes.Count; a++)
                {
                    parseDTXML(node.ChildNodes[a], itemList, order);
                }
            }
            else if (node.Name == "output")
            {
                string result = node.Attributes[0].Value;

                Rule temp = new Rule(result, itemList);

                if (result != "p")
                {
                    TESTCASE_LIST[order].addRule(temp);
                }
            }

            if (itemList.Count > 1)
                itemList.RemoveAt(itemList.Count - 1);
        }
Exemple #2
0
        //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;
        }
Exemple #3
0
        //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();
        }
Exemple #4
0
        //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;
        }
Exemple #5
0
        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);
            }
        }
Exemple #6
0
        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;
        }
Exemple #7
0
        public void addRule(Rule param1)
        {
            Rule temp = new Rule();
            temp.setEqualTo(param1);

            RuleList.Add(temp);
        }
Exemple #8
0
 public void setEqualTo(Rule rhs)
 {
     setResult(rhs.getResult());
     setItemList(rhs.getItemList());
 }