public override AnalyzeResult Analyse(IPageData pageData)
        {
            var htmlSizeAnalysis = new AnalyzeResult();

            var byteCount          = _byteSizeHelper.GetByteSize(pageData.Document.InnerHtml);
            var htmlSizeResultRule = new ResultRule();

            if (byteCount < MaximumSizeInKb)
            {
                htmlSizeResultRule.Alias = "html_size_small";
                htmlSizeResultRule.Type  = ResultType.Success;
            }
            else
            {
                htmlSizeResultRule.Alias = "htmlsizeanalyzer_html_size_too_large";
                htmlSizeResultRule.Type  = ResultType.Warning;
            }
            htmlSizeResultRule.Tokens.Add(_byteSizeHelper.GetSizeSuffix(byteCount));
            htmlSizeAnalysis.ResultRules.Add(htmlSizeResultRule);

            return(htmlSizeAnalysis);
        }
예제 #2
0
        public void GetSizeSuffix_OnExecuteWithValue0_Returns0Bytes()
        {
            var suffix = _byteSizeHelper.GetSizeSuffix(0);

            Assert.AreEqual("0 bytes", suffix);
        }