Exemple #1
0
        public Analysis GetAnalysis()
        {
            var analysis = new Analysis();

            var titleAnalyzer = new TitleAnalyzer();

            analysis.Results.Add(titleAnalyzer.Analyse(_htmlResult.Document));

            var metaDescriptionAnalyzer = new MetaDescriptionAnalyzer();

            analysis.Results.Add(metaDescriptionAnalyzer.Analyse(_htmlResult.Document));

            var metaKeywordAnalyzer = new MetaKeywordAnalyzer();

            analysis.Results.Add(metaKeywordAnalyzer.Analyse(_htmlResult.Document));

            var imagesAnalyzer = new ImageTagAnalyzer();

            analysis.Results.Add(imagesAnalyzer.Analyse(_htmlResult.Document));

            var anchorAnalyzer = new AnchorTagAnalyzer();

            analysis.Results.Add(anchorAnalyzer.Analyse(_htmlResult.Document));

            var deprecatedTagAnalyzer = new DeprecatedTagAnalyzer();

            analysis.Results.Add(deprecatedTagAnalyzer.Analyse(_htmlResult.Document));

            var metaRobotsAnalyzer = new MetaRobotsAnalyzer();

            analysis.Results.Add(metaRobotsAnalyzer.Analyse(_htmlResult.Document));

            return(analysis);
        }
Exemple #2
0
        public void Analyse_OnExecuteWithMetaDescriptionValueWith150Charachters_SetsAnalyzeResult()
        {
            var description = "";

            for (int i = 0; i < 150; i++)
            {
                description += "t";
            }

            var doc = new HtmlDocument();

            doc.LoadHtml($"<div><meta name=\"description\" content=\"{description}\" /></div>");

            var pageData = new PageData()
            {
                Document     = doc.DocumentNode,
                Focuskeyword = "focus",
                Url          = "http://www.google.com"
            };

            var analyzer = new MetaDescriptionAnalyzer(new HtmlTagHelper(), new OptionHelper());

            analyzer.Analyse(pageData);
            var result = analyzer.AnalyzeResult;

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ResultRules.Count == 1);
            Assert.AreEqual(ResultType.Success, result.ResultRules.First().Type);
            Assert.AreEqual("description_perfect", result.ResultRules.First().Alias);
        }
Exemple #3
0
        public void Analyse_OnExecuteWithNoMetaTags_SetsAnalyzeResult()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml("<div>focus</div>");

            var pageData = new PageData()
            {
                Document     = doc.DocumentNode,
                Focuskeyword = "focus",
                Url          = "http://www.google.com"
            };

            var analyzer = new MetaDescriptionAnalyzer(new HtmlTagHelper(), new OptionHelper());

            analyzer.Analyse(pageData);
            var result = analyzer.AnalyzeResult;

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ResultRules.Count == 1);
            Assert.AreEqual(ResultType.Error, result.ResultRules.First().Type);
            Assert.AreEqual("no_meta_tag", result.ResultRules.First().Alias);
        }
Exemple #4
0
        public void Analyse_OnExecuteWithNullParameter_ThrowArgumentNullException()
        {
            var analyzer = new MetaDescriptionAnalyzer(new HtmlTagHelper(), new OptionHelper());

            analyzer.Analyse(null);
        }