/// <summary>
        /// Returns the index of the current build.
        /// </summary>
        private static int GetCurrentBuildIndex(
            IList <BuildTestCount> allBuildTestCounts,
            Model.Projects.Build currentBuild)
        {
            var lastBuildTestCounts = allBuildTestCounts.Last
                                      (
                buildTestCount => buildTestCount.BuildId == currentBuild.Id
                                      );

            return(allBuildTestCounts.IndexOf(lastBuildTestCounts));
        }
Example #2
0
        /// <summary>
        /// Returns table entries for each test class.
        /// </summary>
        public static IList <TestClassTableEntry> GetTestClassResults(
            Checkpoint checkpoint,
            Model.Projects.Build build,
            Func <TestResult, string> testUrlBuilder)
        {
            var testClasses = build.Commit.Project.TestClasses;

            return(build.TestResults.GroupBy(result => result.ClassName)
                   .OrderBy
                   (
                       result => testClasses.FirstOrDefault
                       (
                           testClass => testClass.ClassName == result.Key
                       )?.Order ?? 0
                   )
                   .Where
                   (
                       group => testClasses.Any
                       (
                           testClass => testClass.ClassName == group.Key
                       )

                       &&

                       (
                           checkpoint == null ||
                           (
                               checkpoint.TestClasses?.Any
                               (
                                   testClass => testClass.TestClass.ClassName == group.Key
                               ) ?? false
                           )
                       )
                   )
                   .Select
                   (
                       group => new TestClassTableEntry
                       (
                           testClasses.Single(testClass => testClass.ClassName == group.Key),
                           checkpoint?.TestClasses
                           ?.FirstOrDefault(tc => tc.TestClass.ClassName == group.Key)
                           ?.Required ?? false,
                           group.OrderBy(t => t.TestName).ToList(),
                           testUrlBuilder
                       )
                   ).ToList());
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public TestTrendViewModel(
            IList <BuildTestCount> allBuildTestCounts,
            string projectName,
            Model.Projects.Build currentBuild,
            bool thumbnail,
            ITimeZoneProvider timeZoneProvider)
        {
            AllBuildTestCounts = GetTestCounts(allBuildTestCounts);

            ProjectName = projectName;

            CurrentBuildIndex = currentBuild != null
                                ? GetCurrentBuildIndex(AllBuildTestCounts, currentBuild)
                                : (int?)null;

            Thumbnail = thumbnail;

            _timeZoneProvider = timeZoneProvider;
        }