public void AddPageTest() { IPagesStorageProviderV30 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV30>(); mocks.ReplayAll(); Host.Instance = new Host(); Collectors.IndexDirectoryProvider = new DummyIndexDirectoryProvider(); ProviderLoader.SetUp <IIndexDirectoryProviderV30>(typeof(DummyIndexDirectoryProvider), ""); string pageTitle = "This page is the title of the page"; string pageContent = "This is the content of the page"; PageContent page = new PageContent(new PageInfo("pagefullname", pagesStorageProvider, DateTime.Now), pageTitle, "user-test", DateTime.Now, "comment to last editing", pageContent, null, "Description of the page"); Assert.IsTrue(SearchClass.IndexPage(page)); List <SearchResult> results = SearchClass.Search(new SearchField[] { SearchField.Title }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument documentPage = results[0].Document as PageDocument; Assert.AreEqual("This <b class=\"searchkeyword\">page</b> is the title of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedContent, "Wrong content"); }
public void AddPageTest() { IPagesStorageProviderV60 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV60>(); Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any(); mocks.ReplayAll(); Collectors.InitCollectors(); Collectors.AddProvider(typeof(FSIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(FSIndexDirectoryProvider)), "", typeof(IIndexDirectoryProviderV60)); Host.Instance = new Host(); Host.Instance.OverridePublicDirectory(testDir); ProviderLoader.SetUp <IIndexDirectoryProviderV60>(typeof(FSIndexDirectoryProvider), ""); string pageTitle = "This is the title of the page"; string pageContent = "This is the content of the page"; PageContent page = new PageContent("pagefullname", pagesStorageProvider, DateTime.Now, pageTitle, "user-test", DateTime.Now, "comment to last editing", pageContent, null, "Description of the page"); Assert.IsTrue(SearchClass.IndexPage(page)); List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument documentPage = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedContent, "Wrong content"); }
public void UnindexPageTest() { IPagesStorageProviderV40 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV40>(); Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any(); mocks.ReplayAll(); Collectors.InitCollectors(); Collectors.AddProvider(typeof(AzureIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(AzureIndexDirectoryProvider)), ConfigurationManager.AppSettings["AzureConnString"], typeof(IIndexDirectoryProviderV40)); Host.Instance = new Host(); Host.Instance.OverridePublicDirectory(testDir); ProviderLoader.SetUp <IIndexDirectoryProviderV40>(typeof(AzureIndexDirectoryProvider), ConfigurationManager.AppSettings["AzureConnString"]); string pageTitle1 = "This is the title"; string pageContent1 = "This is the content of the page"; PageContent page1 = new PageContent("pagefullname1", pagesStorageProvider, DateTime.Now, pageTitle1, "user-test", DateTime.Now, "comment to last editing", pageContent1, null, "Description of the page"); string pageTitle2 = "This is the title of the second page"; string pageContent2 = "This is the content of the second page"; PageContent page2 = new PageContent("pagefullname2", pagesStorageProvider, DateTime.Now, pageTitle2, "user-test", DateTime.Now, "comment to last editing", pageContent2, null, "Description of the page"); Lucene.Net.Store.Directory directory = new RAMDirectory(); Assert.IsTrue(SearchClass.IndexPage(page1)); Assert.IsTrue(SearchClass.IndexPage(page2)); List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(2, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[1].DocumentType, "Wrong document type"); PageDocument doc1 = results[1].Document as PageDocument; Assert.AreEqual(string.Empty, doc1.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", doc1.HighlightedContent, "Wrong content"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument doc2 = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedContent, "Wrong content"); Assert.IsTrue(SearchClass.UnindexPage(page1)); results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument doc3 = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedContent, "Wrong content"); }
public void UnindexPageTest() { IPagesStorageProviderV30 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV30>(); mocks.ReplayAll(); Host.Instance = new Host(); Collectors.IndexDirectoryProvider = new DummyIndexDirectoryProvider(); ProviderLoader.SetUp <IIndexDirectoryProviderV30>(typeof(DummyIndexDirectoryProvider), ""); string pageTitle1 = "This is the title"; string pageContent1 = "This is the content of the page"; PageContent page1 = new PageContent(new PageInfo("pagefullname1", pagesStorageProvider, DateTime.Now), pageTitle1, "user-test", DateTime.Now, "comment to last editing", pageContent1, null, "Description of the page"); string pageTitle2 = "This is the title of the second page"; string pageContent2 = "This is the content of the second page"; PageContent page2 = new PageContent(new PageInfo("pagefullname2", pagesStorageProvider, DateTime.Now), pageTitle2, "user-test", DateTime.Now, "comment to last editing", pageContent2, null, "Description of the page"); Lucene.Net.Store.Directory directory = new RAMDirectory(); Assert.IsTrue(SearchClass.IndexPage(page1)); Assert.IsTrue(SearchClass.IndexPage(page2)); List <SearchResult> results = SearchClass.Search(new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(2, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[1].DocumentType, "Wrong document type"); PageDocument doc1 = results[1].Document as PageDocument; Assert.AreEqual(string.Empty, doc1.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", doc1.HighlightedContent, "Wrong content"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument doc2 = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedContent, "Wrong content"); Assert.IsTrue(SearchClass.UnindexPage(page1)); results = SearchClass.Search(new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument doc3 = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedContent, "Wrong content"); }