private IEnumerable <RhinoTestCase> GetTests(string issueKey) { // get issue type var issueType = jiraClient.GetIssueType(issueKey); var capability = string.Empty; var typeEntry = capabilities.Where(i => $"{i.Value}".Equals(issueType, Compare)); if (typeEntry.Any()) { capability = $"{typeEntry.ElementAt(0).Key}"; } // get fetching method var method = GetType() .GetMethods(BindingFlags.Instance | BindingFlags.NonPublic) .Where(i => i.GetCustomAttribute <DescriptionAttribute>() != null) .FirstOrDefault(i => i.GetCustomAttribute <DescriptionAttribute>().Description.Equals(capability, Compare)); // exit conditions if (method == default) { logger?.Error($"Get-Tests -By [{issueType}] = false"); return(Array.Empty <RhinoTestCase>()); } // invoke and return results return(method.Invoke(this, new object[] { issueKey }) as IEnumerable <RhinoTestCase>); }
/// <summary> /// Returns a list of test cases for a project. /// </summary> /// <param name="ids">A list of test ids to get test cases by.</param> /// <returns>A collection of Rhino.Api.Contracts.AutomationProvider.RhinoTestCase</returns> public override IEnumerable <RhinoTestCase> OnGetTestCases(params string[] ids) { // setup: issues map var map = new ConcurrentDictionary <string, string>(); // build issues map Parallel.ForEach(ids, options, id => map[id] = jiraClient.GetIssueType(idOrKey: id)); // entities var byTests = map .Where(i => i.Value.Equals($"{capabilities[AtlassianCapabilities.TestType]}", Compare)) .Select(i => i.Key); var bySets = map .Where(i => i.Value.Equals($"{capabilities[AtlassianCapabilities.SetType]}", Compare)) .Select(i => i.Key); var byPlans = map .Where(i => i.Value.Equals($"{capabilities[AtlassianCapabilities.PlanType]}", Compare)) .Select(i => i.Key); var byExecutions = map .Where(i => i.Value.Equals($"{capabilities[AtlassianCapabilities.ExecutionType]}", Compare)) .Select(i => i.Key); // setup var testCases = new ConcurrentBag <RhinoTestCase>(); // get and apply var onTestCases = GetByTests(byTests); testCases.AddRange(onTestCases); onTestCases = GetBySets(bySets); testCases.AddRange(onTestCases); onTestCases = GetByPlans(byPlans); testCases.AddRange(onTestCases); onTestCases = GetByExecutions(byExecutions); testCases.AddRange(onTestCases); // results return(testCases); }