コード例 #1
0
        public void WhenDocumentIsEmpty_GetTextsCount_ShouldReturnZeroCount()
        {
            htmlService.Setup(f => f.GetDocument(It.IsAny <Uri>())).Returns(mockDocumentProvider.GetHtmlDocument_Empty());

            IContentParser parser = new ContentParser(htmlService.Object);
            var            stats  = parser.GetDocumentStats(url);

            Assert.IsTrue(stats.TotalCount == 0, "Words count should be 0");
        }
コード例 #2
0
        public void WhenDocumentIsNotEmpty_GetTextsCount_ShouldReturnValidCount()
        {
            htmlService.Setup(f => f.GetDocument(It.IsAny <Uri>())).Returns(mockDocumentProvider.GetHtmlDocument_WithTexts());

            IContentParser parser = new ContentParser(htmlService.Object);
            var            stats  = parser.GetDocumentStats(url);

            Assert.IsNotNull(stats, "Html document stats not valid");
            Assert.IsTrue(stats.TotalCount > 0, "Words count should not be 0");
        }
コード例 #3
0
        public void WhenDocumentIsNotEmpty_GetTopTextsCount_ShouldReturnValidCount()
        {
            htmlService.Setup(f => f.GetDocument(It.IsAny <Uri>())).Returns(mockDocumentProvider.GetHtmlDocument_WithTexts());

            IContentParser parser = new ContentParser(htmlService.Object);
            var            stats  = parser.GetDocumentStats(url);

            Assert.IsNotNull(stats, "Html document stats not valid");
            Assert.IsTrue(stats.CountByWords.Count > 0, "Top Words count should not be 0");

            var unitWord = stats.CountByWords["unit"];

            Assert.IsTrue(unitWord == 4, "count of word \"unit\" should be 4");

            var softwareWord = stats.CountByWords["software"];

            Assert.IsTrue(softwareWord == 3, "count of word \"software\" should be 4");
        }