/// <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)
        {
            // constants: logging
            const string M1 = "tests-repository parsed into integers";
            const string M2 = "total of [{0}] distinct items found (test or test-suite)";

            // parse as int
            var idList = new List <(string schema, int id)>();

            foreach (var id in Configuration.TestsRepository)
            {
                idList.Add(GetSchema(id));
            }
            logger?.Debug(M1);

            // normalize
            var cases = idList.Where(i => i.schema.Equals("C", Compare)).Select(i => i.id).Distinct();
            var suits = idList.Where(i => !i.schema.Equals("C", Compare)).Select(i => i.id).Distinct();

            logger?.DebugFormat(M2, idList.Count);

            // get all test-cases
            var bySuites = suits.SelectMany(i => casesClient.GetCases(project.Id, i)).Where(i => i != null) ?? Array.Empty <TestRailCase>();
            var byCases  = cases.Select(i => casesClient.GetCase(i)).Where(i => i != null) ?? Array.Empty <TestRailCase>();

            return(bySuites.Concat(byCases).DistinctBy(i => i.Id).Select(ToConnectorTestCase));
        }
コード例 #2
0
        private void AddToCaseRefs(RhinoTestCase testCase, string bugKey)
        {
            // exit conditions
            if (string.IsNullOrEmpty(bugKey))
            {
                return;
            }

            // setup
            _ = int.TryParse(testCase.Key, out int caseId);

            // get
            var onTestCase = casesClient.GetCase(caseId);
            var refs       = onTestCase.Refs == null
                ? new[] { bugKey }
                : onTestCase.Refs.Split(',').Concat(new[] { bugKey });

            // update
            onTestCase.Refs = refs.Any() ? string.Join(",", refs) : default;
            casesClient.UpdateCase(caseId, onTestCase);
        }