//RB: This function below bulk fill the results and add comments public static void FillTheResultsBulkAndCloseTheRun(JObject tr, JArray getRun, Dictionary <string, Tuple <int, string> > dict) { var st = tr.First; string[] ids = (st.ToString()).Split(':'); var runId = ids[1].TrimStart(); // RunID var request = new AddResultsRequest(); foreach (var item in getRun.Children()) { var obj = JObject.Parse(item.ToString()); var title = (string)obj.SelectToken("title"); var id = (string)obj.SelectToken("id"); int res = (int)obj.SelectToken("status_id"); var comment = (string)obj.SelectToken("comment"); if (dict.ContainsKey(title)) { var tupleStatusComment = dict[title]; res = tupleStatusComment.Item1; comment = tupleStatusComment.Item2; AddResultsRequest.AddResultsItem addItem = new AddResultsRequest.AddResultsItem(); addItem.test_id = id; addItem.status_id = res; addItem.comment = comment; request.results.Add(addItem); } } TestExporter.AddTestResults("add_results/" + runId, request); TestExporter.Post("close_run/" + runId); }
//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()] + "§ion_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); } }