コード例 #1
0
        public void SearchEngineService_MoreLikeThisSearch_WithMinDocumentSet_ReturnsEmptySet()
        {
            _service.Dispose();
            _service = new SearchEngineService(new RAMDirectory(), new SnowballAnalyzer("English", stopWords), new FullTextSearchEngineSettings()
            {
                Parameters = new TuningParameters()
                {
                    MinimumDocumentFrequency = 20
                }
            });

            for (int i = 1; i <= 10; i++)
            {
                _service.AddPost(new SearchEngineEntry()
                {
                    EntryId     = i,
                    Body        = "This is a sample post",
                    Title       = "This is the title of the post",
                    Tags        = ".net, mvc, post",
                    BlogName    = "MyTestBlog",
                    IsPublished = true,
                    PublishDate = DateTime.Now,
                    EntryName   = "this-is-the-title"
                }
                                 );
            }


            var result = _service.RelatedContents(1, 100, 0) as List <SearchEngineResult>;

            Assert.AreEqual(0, result.Count());
        }
コード例 #2
0
        public void SearchEngineService_WithEntry_AddsToIndex()
        {
            _service.AddPost(new SearchEngineEntry
            {
                EntryId     = 1,
                Body        = "This is a sample post",
                Title       = "This is the title",
                Tags        = "Title",
                BlogName    = "MyTestBlog",
                IsPublished = true,
                PublishDate = DateTime.Now,
                EntryName   = "this-is-the-title"
            }
                             );

            _service.AddPost(new SearchEngineEntry
            {
                EntryId     = 2,
                Body        = "This is another sample post",
                Title       = "This is another title",
                Tags        = "Title another",
                BlogName    = "MyTestBlog",
                IsPublished = true,
                PublishDate = DateTime.Now,
                EntryName   = "this-is-the-title"
            }
                             );

            var result = _service.Search("sample", 100, 0) as List <SearchEngineResult>;

            Assert.AreEqual(2, result.Count);
        }
コード例 #3
0
        public void SearchEngineService_MoreLikeThisSearch_WithMinDocumentSet_ReturnsEmptySet()
        {
            _service.Dispose();
            _service = new SearchEngineService(new RAMDirectory(), new SnowballAnalyzer("English", stopWords), new FullTextSearchEngineSettings() { Parameters = new TuningParameters() { MinimumDocumentFrequency = 20 } });

            for (int i = 1; i <= 10; i++)
            {
                _service.AddPost(new SearchEngineEntry()
                {
                    EntryId = i,
                    Body = "This is a sample post",
                    Title = "This is the title of the post",
                    Tags = ".net, mvc, post",
                    BlogName = "MyTestBlog",
                    IsPublished = true,
                    PublishDate = DateTime.UtcNow,
                    EntryName = "this-is-the-title"
                }
                );
            }

            var result = _service.RelatedContents(1, 100, 0) as List<SearchEngineResult>;
            Assert.AreEqual(0, result.Count());
        }