//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; }
public void setEqualTo(Configuration rhs) { setResult(rhs.getResult()); setItemList(rhs.getItemList()); }
static List<Item> getOptionsWithTheseNames(Configuration param1, List<string> names) { List<Item> result = new List<Item>(); List<Item> itemList = param1.getItemList(); for (int a = 0; a < names.Count; a++) { string nameToCheck = names[a]; for (int b = 0; b < itemList.Count; b++) { if (itemList[b].getObjectName() == nameToCheck) { Item temp = new Item(); temp.setEqualTo(itemList[b]); result.Add(temp); } } } return result; }
//checks if the items in input list exists in any passing configuration static bool doWeHaveThisConfiguration(List<Item> input, int order) { for (int counter = 0; counter < TESTCASE_LIST[order].getPassingList().Count; counter++) { Configuration passConf = new Configuration(); passConf.setEqualTo(TESTCASE_LIST[order].getPassingList()[counter]); List<Item> passOptions = passConf.getItemList(); bool exists = true; for (int a = 0; a < input.Count; a++) { if (!doesExist(passOptions, input[a])) exists = false; } if (exists) return true; } for (int counter = 0; counter < TESTCASE_LIST[order].getAddedList().Count; counter++) { Configuration passConf = new Configuration(); passConf.setEqualTo(TESTCASE_LIST[order].getAddedList()[counter]); List<Item> passOptions = passConf.getItemList(); bool exists = true; for (int a = 0; a < input.Count; a++) { if (!doesExist(passOptions, input[a])) exists = false; } if (exists) return true; } return false; }
//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; }
//given a changed configuration, check if that configuration was in TRIPLE_LIST before static bool doesExistInScoreList(Configuration input) { for (int counter = 0; counter < TRIPLET_LIST.Count; counter++) { bool exists = true; Triplet tempTrip = new Triplet(); tempTrip.setEqualTo(TRIPLET_LIST[counter]); List<Item> tripOptionList = tempTrip.getChangedConf().getItemList(); List<Item> inputOptionList = input.getItemList(); for (int a = 0; a < inputOptionList.Count; a++) { if (!doesExist(tripOptionList, inputOptionList[a])) exists = false; } if (exists) return true; } return false; }
static void print(Configuration param1) { string result = param1.getResult(); List<Item> options = param1.getItemList(); Console.Write("result=" + result + " "); for (int a = 0; a < options.Count; a++) Console.Write(options[a].getObjectName() + "=" + options[a].getObjectValue() + " "); Console.Write("\n"); }