Пример #1
0
        //RB: This function is a workaround to delete several tests in a row
        public static void DeleteTestsWorkAround(Dictionary <string, Tuple <int, string> > testsFromFile, string path, object project, Dictionary <string, string> dictNameSuite, Dictionary <string, string> dictNameSections, object suiteName, object sectionName)
        {
            var getCases = TestExporter.Get1("get_cases/" +
                                             AppSettings[project.ToString()] + "&suite_id=" +
                                             dictNameSuite[suiteName.ToString()] + "&section_id=" +
                                             dictNameSections[sectionName.ToString()]);

            List <string> ListCasesToDelete = new List <string>();

            if (getCases.Count != 0)
            {
                // List the tests that are not in the file
                foreach (var item in getCases.Children())
                {
                    var obj   = JObject.Parse(item.ToString());
                    var title = (string)obj.SelectToken("title");
                    if (!testsFromFile.Keys.Contains(title))
                    {
                        ListCasesToDelete.Add(title);
                    }
                }
                // Create a section
                TestExporter.CreateSection("add_section/" + AppSettings[project.ToString()], "TestsToBeDeleted");

                // Get the section and section Id
                dictNameSections = GetSections(project, dictNameSuite, suiteName.ToString());
                string sectionId = dictNameSections["TestsToBeDeleted"];

                // Add the unnecessary tests to the section
                foreach (var elem in ListCasesToDelete)
                {
                    JObject r = TestExporter.CreateTestName("add_case/" + sectionId, elem);
                }

                // Delete the section
                TestExporter.Post("delete_section/" + sectionId);
            }
        }