Exemple #1
0
        public void CanRemoveItemFromIndex()
        {
            CreateIndex(1);

            using (SearchEngineService ses = SearchEngineService.GetByCloset(1))
            {
                int totalEntry = ses.GetTotalIndexedEntryCount();
                ses.RemovePost(2);
                Assert.IsTrue(ses.GetTotalIndexedEntryCount() == totalEntry - 1);
            }
        }
        public void RebuildIndex_AddsDataToIndex()
        {
            var context    = new Mock <ISubtextContext>();
            var repository = new Mock <ObjectRepository>();

            repository.Setup(r => r.GetEntries(PostType.BlogPost, null, It.IsAny <int>(), It.IsAny <int>())).Returns(
                BuildFakeCollection());
            context.Setup(c => c.Repository).Returns(repository.Object);

            var indexService = new IndexingService(context.Object, _service);

            indexService.RebuildIndex();

            Assert.AreEqual(1, _service.GetTotalIndexedEntryCount());
        }
        public void SearchEngineService_ReturnsCorrectTotalNumber()
        {
            _service.AddPost(new SearchEngineEntry()
            {
                EntryId     = 1,
                BlogId      = 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,
                BlogId      = 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"
            }
                             );

            int totNumber = _service.GetTotalIndexedEntryCount();

            Assert.AreEqual(2, totNumber);
        }