private async Task <TestResultsGroupData[]> GetTestResultsWithWorkItemsAsync(TestResultsDetails resultIdsToFetch)
        {
            TestResultsDetailsForGroup[] resultDetailGroupsToParse =
                resultIdsToFetch.ResultsForGroup.ToArray();

            var testResultDetailsParser = GetParser(resultIdsToFetch);

            var filteredTestResultGroups = await resultIdsToFetch
                                           .ResultsForGroup
                                           .ParallelSelectAsync(async resultsForGroup =>
            {
                var resultGroup = new TestResultsGroupData
                {
                    GroupName = testResultDetailsParser.GetGroupByValue(resultsForGroup)
                };

                var results  = await GetTestResultsWithBugRefsAsync(resultsForGroup);
                var bugsRefs = results.Select(result => result.AssociatedBugRefs).Merge();

                var workItemDictionary = await GetWorkItemsAsync(bugsRefs);

                SetAssociatedBugs(results, workItemDictionary);
                results.ForEach(resultGroup.AddTestResult);
                return(resultGroup);
            });

            return(filteredTestResultGroups);
        }
        private void SetGroupName(TestResultsGroupData resultsGroupData, EmailReportConfiguration emailReportConfig)
        {
            var groupTestResultsBy = emailReportConfig.ReportDataConfiguration.GroupTestResultsBy;

            GroupName = groupTestResultsBy == TestResultsGroupingType.Priority ?
                        PriorityDisplayNameHelper.GetDisplayName(resultsGroupData.GroupName) :
                        resultsGroupData.GroupName;
        }
 public TestResultsGroupViewModel(TestResultsGroupData resultsGroupData, EmailReportConfiguration emailReportConfig)
 {
     SetGroupName(resultsGroupData, emailReportConfig);
     FailedTests = GetTestResultViewModels(resultsGroupData, emailReportConfig.PipelineConfiguration, TestOutcome.Failed);
     PassedTests = GetTestResultViewModels(resultsGroupData, emailReportConfig.PipelineConfiguration, TestOutcome.Passed);
     OtherTests  = GetTestResultViewModels(resultsGroupData, emailReportConfig.PipelineConfiguration,
                                           EnumHelper.GetEnumsExcept(TestOutcome.Failed, TestOutcome.Passed));
 }
Example #4
0
        public static List <TestResultData> GetTestResultsByOutcomes(this TestResultsGroupData source,
                                                                     params TestOutcome[] outcomes)
        {
            var testResults = new List <TestResultData>();

            foreach (TestOutcome outcome in outcomes)
            {
                if (source.TestResults.ContainsKey(outcome))
                {
                    testResults.AddRange(source.TestResults[outcome]);
                }
            }
            return(testResults);
        }
Example #5
0
        public static void AddTestResult(this TestResultsGroupData source, TestResultData result)
        {
            if (!string.IsNullOrEmpty(result.TestResult.Outcome))
            {
                var testOutcome = EnumHelper.Parse <TestOutcome>(result.TestResult.Outcome);
                if (!source.TestResults.ContainsKey(testOutcome))
                {
                    source.TestResults[testOutcome] = new List <TestResultData>();
                }

                source.TestResults[testOutcome].Add(result);
            }
            else
            {
                // TODO - Log.LogWarning(
                //"Found test with outcome as null. " +
                //$"Test result id {result.TestResult.Id} in Test run {result.TestResult.TestRun?.Id}");
            }
        }
 private static List <TestResultViewModel> GetTestResultViewModels(TestResultsGroupData resultsGroupData,
                                                                   PipelineConfiguration config, params TestOutcome[] testOutcomes)
 {
     return(resultsGroupData.GetTestResultsByOutcomes(testOutcomes)
            .Select(result => new TestResultViewModel(result, config)).ToList());
 }