Esempio n. 1
0
        public void Alias_OnSet_SetsAliasOfAnalyzeResult()
        {
            var randomAnalyzer = new KeywordHeadingAnalyzer();

            Assert.AreEqual(null, randomAnalyzer.Alias);
            Assert.AreEqual(null, randomAnalyzer.AnalyzeResult.Alias);
            randomAnalyzer.Alias = "test";
            Assert.AreEqual("test", randomAnalyzer.Alias);
            Assert.AreEqual("test", randomAnalyzer.AnalyzeResult.Alias);
        }
Esempio n. 2
0
        public void Weight_OnSet_SetsWeightOfAnalyzeResult()
        {
            var randomAnalyzer = new KeywordHeadingAnalyzer();

            Assert.AreEqual(0, randomAnalyzer.Weight);
            Assert.AreEqual(100, randomAnalyzer.AnalyzeResult.Weight); // default value
            randomAnalyzer.Weight = 55;
            Assert.AreEqual(55, randomAnalyzer.Weight);
            Assert.AreEqual(55, randomAnalyzer.AnalyzeResult.Weight);
        }
Esempio n. 3
0
        public Analysis GetAnalysis()
        {
            var analysis = new Analysis();

            if (!string.IsNullOrEmpty(FocusKeyword) && FocusKeyword != "undefined")
            {
                FocusKeyword = FocusKeyword.ToLower();

                var wordOccurenceService = new WordOccurenceService();

                var topwords = wordOccurenceService.GetKeywords(_htmlResult);

                var information = new AnalysisInformation {
                    Alias = "keywordanalyzer_top_words"
                };
                information.Tokens.Add(FocusKeyword);
                foreach (var word in topwords)
                {
                    information.Tokens.Add(word.Key);
                    information.Tokens.Add(word.Value.ToString());
                }

                analysis.Information.Add(information);


                var keywordTitleAnalyzer = new KeywordTitleAnalyzer();
                analysis.Results.Add(keywordTitleAnalyzer.Analyse(_htmlResult.Document, FocusKeyword));

                var keywordMetaDescriptionAnalyzer = new KeywordMetaDescriptionAnalyzer();
                analysis.Results.Add(keywordMetaDescriptionAnalyzer.Analyse(_htmlResult.Document, FocusKeyword));

                var keywordUrlAnalyzer = new KeywordUrlAnalyzer();
                analysis.Results.Add(keywordUrlAnalyzer.Analyse(_htmlResult.Document, FocusKeyword, _htmlResult.Url));

                var keywordContentAnalyzer = new KeywordContentAnalyzer();
                analysis.Results.Add(keywordContentAnalyzer.Analyse(_htmlResult.Document, FocusKeyword));

                var keywordHeadingAnalyzer = new KeywordHeadingAnalyzer();
                analysis.Results.Add(keywordHeadingAnalyzer.Analyse(_htmlResult.Document, FocusKeyword));
            }
            else
            {
                var information = new AnalysisInformation {
                    Alias = "keywordanalyzer_focus_keyword_not_set"
                };
                analysis.Information.Add(information);
            }

            return(analysis);
        }
Esempio n. 4
0
        public void Analyse_OnExecuteWithKeywordPresentInH3_SetsAnalyzeResult()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml("<body><h3>focus</h3></body>");

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

            var analyzer = new KeywordHeadingAnalyzer();

            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("1", result.ResultRules.First().Tokens.First());
            Assert.AreEqual("keyword_used_in_heading", result.ResultRules.First().Alias);
        }
Esempio n. 5
0
        public void Analyse_OnExecuteWithNullParameter_ThrowArgumentNullException()
        {
            var analyzer = new KeywordHeadingAnalyzer();

            analyzer.Analyse(null);
        }
Esempio n. 6
0
        public void Constructor_OnExecute_SetsAnalyzeResult()
        {
            var randomAnalyzer = new KeywordHeadingAnalyzer();

            Assert.IsNotNull(randomAnalyzer.AnalyzeResult);
        }