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); }
public PageAnalysis CreatePageAnalysis(IPublishedContent node, string focusKeyword) { var pageAnalysis = new PageAnalysis(); try { var htmlString = _htmlHelper.GetTemplateHtml(node); var htmlResult = _htmlHelper.GetHtmlResult(htmlString); pageAnalysis.Url = node.UrlAbsolute(); pageAnalysis.FocusKeyword = focusKeyword; pageAnalysis.Size = _byteSizeHelper.GetByteSize(htmlString); SetAnalyzerResults(pageAnalysis, htmlResult); } catch (WebException ex) { pageAnalysis.Status = ((HttpWebResponse)ex.Response).StatusCode; } pageAnalysis.Score = _scoreService.GetScore(pageAnalysis); return(pageAnalysis); }
public void GetByteSize_OnExecuteWithNullParameter_Returns0() { var size = _byteSizeHelper.GetByteSize(null); Assert.AreEqual(0, size); }