Esempio n. 1
0
        public void GetPageContent_NullOrEmptyPageContent_ReturnEmptyDictionary(string pageContent)
        {
            IHtmlWebWrapper htmlWeb        = Substitute.For <IHtmlWebWrapper>();
            KeywordsFinder  keyworsdFinder = new KeywordsFinder(htmlWeb);


            var result = keyworsdFinder.FindKeywords(pageContent);


            result.Should().BeEmpty();
        }
Esempio n. 2
0
        public void GetPageContent_KeywordsNotExist_ReturnEmptyDictionary(string keywords)
        {
            IHtmlWebWrapper htmlWeb = Substitute.For <IHtmlWebWrapper>();

            htmlWeb.SelectNodeAttribute(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).Returns(keywords);
            KeywordsFinder keyworsdFinder = new KeywordsFinder(htmlWeb);


            var result = keyworsdFinder.FindKeywords("Test");


            result.Should().BeEmpty();
        }
Esempio n. 3
0
        public void GetPageContent_KeywordsAndBodyExist_ReturnProperDictionary()
        {
            IHtmlWebWrapper htmlWeb = Substitute.For <IHtmlWebWrapper>();

            htmlWeb.SelectNode(Arg.Any <string>(), Arg.Any <string>()).Returns("keywrod keyword1 keyword2 keyword keyword2");
            htmlWeb.SelectNodeAttribute(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).Returns("keyword1, keyword2, keyword1");
            KeywordsFinder keyworsdFinder = new KeywordsFinder(htmlWeb);


            var result = keyworsdFinder.FindKeywords("Test");


            result.Should().BeEquivalentTo(new Dictionary <string, int>
            {
                { "keyword2", 2 },
                { "keyword1", 1 },
            });
        }