private static AppConfigTestCategory GetTestCategoryFromConfig(string categoryConfigFile) { if (string.IsNullOrEmpty(categoryConfigFile) || !File.Exists(categoryConfigFile)) { return(null); } XmlDocument doc = new XmlDocument(); doc.XmlResolver = null; XmlReaderSettings settings = new XmlReaderSettings(); settings.XmlResolver = null; settings.DtdProcessing = DtdProcessing.Prohibit; XmlReader xmlReader = XmlReader.Create(categoryConfigFile, settings); doc.Load(xmlReader); AppConfigTestCategory testCategory = new AppConfigTestCategory(); var testCaseNodes = doc.DocumentElement.SelectNodes("TestCase"); foreach (XmlNode testCaseNode in testCaseNodes) { AppConfigTestCase testCase = new AppConfigTestCase(); // Get test case name. testCase.Name = testCaseNode.Attributes["name"].Value; // Get test case categories. List <string> testCategories = new List <string>(); foreach (XmlNode categoryNode in testCaseNode.SelectNodes("Category")) { string categoryName = categoryNode.Attributes["name"].Value; if (!testCategories.Contains(categoryName)) { testCategories.Add(categoryName); } } testCase.Categories = testCategories; testCategory.TestCases.Add(testCase); } return(testCategory); }
private static AppConfigTestCategory GetTestCategoryFromConfig(string categoryConfigFile) { if (string.IsNullOrEmpty(categoryConfigFile) || !File.Exists(categoryConfigFile)) { return null; } XmlDocument doc = new XmlDocument(); doc.XmlResolver = null; XmlReaderSettings settings = new XmlReaderSettings(); settings.XmlResolver = null; settings.DtdProcessing = DtdProcessing.Prohibit; XmlReader xmlReader = XmlReader.Create(categoryConfigFile, settings); doc.Load(xmlReader); AppConfigTestCategory testCategory = new AppConfigTestCategory(); var testCaseNodes = doc.DocumentElement.SelectNodes("TestCase"); foreach (XmlNode testCaseNode in testCaseNodes) { AppConfigTestCase testCase = new AppConfigTestCase(); // Get test case name. testCase.Name = testCaseNode.Attributes["name"].Value; // Get test case categories. List<string> testCategories = new List<string>(); foreach (XmlNode categoryNode in testCaseNode.SelectNodes("Category")) { string categoryName = categoryNode.Attributes["name"].Value; if (!testCategories.Contains(categoryName)) { testCategories.Add(categoryName); } } testCase.Categories = testCategories; testCategory.TestCases.Add(testCase); } return testCategory; }