예제 #1
0
        public void SuccessCountProperty_OnSet_SetsTheValue()
        {
            var pageScore = new PageScore();

            pageScore.SuccessCount = 100;

            Assert.AreEqual(100, pageScore.SuccessCount);
        }
예제 #2
0
        public void OverallScoreProperty_OnSet_SetsTheValue()
        {
            var pageScore = new PageScore();

            pageScore.OverallScore = 100;

            Assert.AreEqual(100, pageScore.OverallScore);
        }
예제 #3
0
        private int CalculateScore(Analysis analysis, PageScore pageScore)
        {
            var totalScore = 0;

            foreach (var result in analysis.Results)
            {
                pageScore.ErrorCount   += result.ErrorCount;
                pageScore.WarningCount += result.WarningCount;
                pageScore.HintCount    += result.HintCount;
                pageScore.SuccessCount += result.SuccessCount;
                result.Score            = GetResultScore(result);
                totalScore             += result.Score;
            }
            return(totalScore);
        }
예제 #4
0
        /// <summary>
        /// Gets the score for a category.
        /// </summary>
        /// <param name="pageAnalysis">The page analysis.</param>
        /// <returns></returns>
        public PageScore GetScore(PageAnalysis pageAnalysis)
        {
            var pageScore  = new PageScore();
            var totalScore = 0;

            foreach (var analyzerResult in pageAnalysis.AnalyzerResults)
            {
                totalScore += CalculateScore(analyzerResult.Analysis, pageScore);
            }

            var numberOfAnalyzers = pageAnalysis.AnalyzerResults.Sum(x => x.Analysis.Results.Count);

            pageScore.OverallScore = totalScore / numberOfAnalyzers;

            return(pageScore);
        }
예제 #5
0
        private PageScore CalculatePageScore(IEnumerable <AnalyzeResult> analyzers)
        {
            var pageScore = new PageScore
            {
                ErrorCount   = analyzers.Sum(x => x.ErrorCount),
                WarningCount = analyzers.Sum(x => x.WarningCount),
                HintCount    = analyzers.Sum(x => x.HintCount),
                SuccessCount = analyzers.Sum(x => x.SuccessCount)
            };
            var totalScore  = analyzers.Sum(CalculateResultScore);
            var totalWeight = analyzers.Sum(x => x.Weight);

            pageScore.OverallScore = CalculateOverallScore(totalScore, totalWeight);

            return(pageScore);
        }
        public PageScore GetScore(PageAnalysis pageAnalysis)
        {
            var pageScore  = new PageScore();
            var totalScore = 0;

            foreach (var analyzerResult in pageAnalysis.AnalyzerResults)
            {
                var analysis = analyzerResult.Analysis;

                foreach (var result in analysis.Results)
                {
                    pageScore.ErrorCount   += result.ErrorCount;
                    pageScore.WarningCount += result.WarningCount;
                    pageScore.HintCount    += result.HintCount;
                    pageScore.SuccessCount += result.SuccessCount;
                    result.Score            = GetResultScore(result);
                    totalScore             += result.Score;
                }
            }
            pageScore.OverallScore = totalScore / pageAnalysis.AnalyzerResults.Sum(x => x.Analysis.Results.Count);

            return(pageScore);
        }
예제 #7
0
 public string Serialize(PageScore score)
 {
     return(base.Serialize(score));
 }