/// <summary> /// Append test case categories from config.xml /// </summary> /// <param name="testCategory">TestCategory of AppConfig.</param> public void AppendCategoryByConfigFile(AppConfigTestCategory testCategory) { List <AppConfigTestCase> testCaseListForSearch = testCategory.TestCases; for (int i = 0; i < TestCaseList.Count; i++) { string testCaseName = TestCaseList[i].Name; for (int j = 0; j < testCaseListForSearch.Count; j++) { if (testCaseListForSearch[j].Name == testCaseName) { List <string> testCategories = testCaseListForSearch[j].Categories; foreach (string category in testCategories) { if (!TestCaseList[i].Category.Contains(category)) { TestCaseList[i].Category.Add(category); } } // Remove item to reduce search scope. testCaseListForSearch.RemoveAt(j); break; } } } }
/// <summary> /// Append test case categories from config.xml /// </summary> /// <param name="testCategory">TestCategory of AppConfig.</param> public void AppendCategoryByConfigFile(AppConfigTestCategory testCategory) { List<AppConfigTestCase> testCaseListForSearch = testCategory.TestCases; for (int i = 0; i < TestCaseList.Count; i++) { string testCaseName = TestCaseList[i].Name; for (int j = 0; j < testCaseListForSearch.Count; j++) { if (testCaseListForSearch[j].Name == testCaseName) { List<string> testCategories = testCaseListForSearch[j].Categories; foreach (string category in testCategories) { if (!TestCaseList[i].Category.Contains(category)) { TestCaseList[i].Category.Add(category); } } // Remove item to reduce search scope. testCaseListForSearch.RemoveAt(j); break; } } } }
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; }