public async Task <IEnumerable <Test> > GetTestsAsync(Int32 RunID) { return(await Task.Run <IEnumerable <Test> > ( async() => { var tests = (JArray)_api.TestRailAPI.SendGet("get_tests/" + RunID); Test[] items = new Test[tests.Count]; var i = 0; foreach (var test in tests) { items[i++] = new Test() { ID = test["id"].Value <Int32>(), Case = await FindCaseAsync(test["case_id"].Value <Int32>()), Status = GlobalStatuses.First(x => x.ID == test["status_id"].Value <Int32>()), Priority = test["priority_id"].Value <Int32?>().HasValue ? GlobalPriorities.First(x => x.ID == test["priority_id"].Value <Int32>()) : new Priority(), Reference = test["refs"].Value <String>() ?? "N/A", Title = test["title"].Value <String>() ?? "N/A", Type = test["type_id"].Value <Int32?>().HasValue ? GlobalCaseTypes.First(x => x.ID == test["type_id"].Value <Int32>()) : new Models.TestRailModels.Type(), Area = (test["custom_area"] != null && test["custom_area"].Value <Int32?>().HasValue) ? GlobalAreas.First(x => x.ID == test["custom_area"].Value <Int32>()): new Area(), Feature = (test["custom_feature"] != null && test["custom_feature"].Value <Int32?>().HasValue) ? GlobalFeatures.First(x => x.ID == test["custom_feature"].Value <Int32>()) : new Feature(), } } ; return items; })); }
public async Task <IEnumerable <Result> > GetResultsForRunAsync(Int32 ID) { return(await Task.Run <IEnumerable <Result> > ( async() => { var results = (JArray)_api.TestRailAPI.SendGet("get_results_for_run/" + ID); List <Result> items = new List <Result>(); var untested = (await GetTestsAsync(ID)).Where(x => x.Status.ID == UNTESTED); foreach (var test in untested) { items.Add( new Result() { ID = 0, Status = test.Status, Test = test, TestedBy = new User(), TestedOn = DateTime.MinValue, Defects = "No defects" }); } foreach (var result in results) { if (result["status_id"].Value <Int32?>().HasValue) { items.Add( new Result() { ID = result["id"].Value <Int32>(), Status = GlobalStatuses.First(x => x.ID == result["status_id"].Value <Int32>()), Test = result["test_id"].Value <Int32?>().HasValue ? await FindTestAsync(result["test_id"].Value <Int32>()) : new Test(), TestedBy = GlobalUsers.First(x => x.ID == result["created_by"].Value <Int32>()), TestedOn = UNIX.FromUnixTime(result["created_on"].Value <Int64>()), Defects = result["defects"].Value <String>() ?? "No defects" }); } } return items; } )); }
public IEnumerable <Test> GetTests(Int32 RunID) { var tests = (JArray)_api.TestRailAPI.SendGet("get_tests/" + RunID); return(tests.Select ( test => new Test() { ID = test["id"].Value <Int32>(), Case = FindCase(test["case_id"].Value <Int32>()), Status = GlobalStatuses.First(x => x.ID == test["status_id"].Value <Int32>()), Priority = test["priority_id"].Value <Int32?>().HasValue ? GlobalPriorities.First(x => x.ID == test["priority_id"].Value <Int32>()) : new Priority(), Reference = test["refs"].Value <String>() ?? "N/A", Title = test["title"].Value <String>() ?? "N/A", Type = test["type_id"].Value <Int32?>().HasValue ? GlobalCaseTypes.First(x => x.ID == test["type_id"].Value <Int32>()) : new Models.TestRailModels.Type(), Area = (test["custom_area"] != null && test["custom_area"].Value <Int32?>().HasValue) ? GlobalAreas.First(x => x.ID == test["custom_area"].Value <Int32>()): new Area(), Feature = (test["custom_feature"] != null && test["custom_feature"].Value <Int32?>().HasValue) ? GlobalFeatures.First(x => x.ID == test["custom_feature"].Value <Int32>()) : new Feature(), })); }
public async Task <Test> FindTestAsync(Int32 ID) { return(await Task.Run <Test> ( async() => { var test = (JObject)_api.TestRailAPI.SendGet("get_test/" + ID); return new Test() { ID = test["id"].Value <Int32>(), Case = await FindCaseAsync(test["case_id"].Value <Int32>()), Status = GlobalStatuses.First(x => x.ID == test["status_id"].Value <Int32>()), Priority = test["priority_id"].Value <Int32?>().HasValue ? GlobalPriorities.First(x => x.ID == test["priority_id"].Value <Int32>()) : new Priority(), Reference = test["refs"].Value <String>() ?? "N/A", Title = test["title"].Value <String>() ?? "N/A", Type = test["type_id"].Value <Int32?>().HasValue ? GlobalCaseTypes.First(x => x.ID == test["type_id"].Value <Int32>()) : new Models.TestRailModels.Type(), Area = (test["custom_area"] != null && test["custom_area"].Value <Int32?>().HasValue) ? GlobalAreas.First(x => x.ID == test["custom_area"].Value <Int32>()): new Area(), Feature = (test["custom_feature"] != null && test["custom_feature"].Value <Int32?>().HasValue) ? GlobalFeatures.First(x => x.ID == test["custom_feature"].Value <Int32>()) : new Feature(), }; } )); }