Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public void Analyse_OnExecuteWithMulitpleRobotsTags_SetsAnalyzeResult()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml("<div><meta name=\"robots\" content=\"\" /><meta name=\"robots\" content=\"\" /></div>");

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

            var analyzer = new MetaRobotsAnalyzer(new HtmlTagHelper());

            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("multiple_robots_tags", result.ResultRules.First().Alias);
        }
Ejemplo n.º 3
0
        public void Analyse_OnExecuteWithMetaGooglebotWithMultipleValuesSet_SetsAnalyzeResult()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml($"<div><meta name=\"googlebot\" content=\"unavailable_after,noimageindex,none\" /></div>");

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

            var analyzer = new MetaRobotsAnalyzer(new HtmlTagHelper());

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

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ResultRules.Count == 3);
            Assert.IsTrue(result.ResultRules.Any(x => x.Type == ResultType.Error));
            Assert.IsTrue(result.ResultRules.Any(x => x.Alias == "googlebot_none"));
        }
Ejemplo n.º 4
0
        public void Analyse_OnExecuteWithMetaGooglebotValueSetNoImageIndex_SetsAnalyzeResult()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml($"<div><meta name=\"googlebot\" content=\"noimageindex\" /></div>");

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

            var analyzer = new MetaRobotsAnalyzer(new HtmlTagHelper());

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

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ResultRules.Count == 1);
            Assert.AreEqual(ResultType.Information, result.ResultRules.First().Type);
            Assert.AreEqual("googlebot_no_image_index", result.ResultRules.First().Alias);
        }
Ejemplo n.º 5
0
        public void Analyse_OnExecuteWithMetaRobotsValueSetToNoFollow_SetsAnalyzeResult()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml($"<div><meta name=\"robots\" content=\"nofollow\" /></div>");

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

            var analyzer = new MetaRobotsAnalyzer(new HtmlTagHelper());

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

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ResultRules.Count == 1);
            Assert.AreEqual(ResultType.Warning, result.ResultRules.First().Type);
            Assert.AreEqual("robots_no_follow", result.ResultRules.First().Alias);
        }
Ejemplo n.º 6
0
        public void Analyse_OnExecuteWithNullParameter_ThrowArgumentNullException()
        {
            var analyzer = new MetaRobotsAnalyzer(new HtmlTagHelper());

            analyzer.Analyse(null);
        }