Beispiel #1
0
        public void AddMessageTest()
        {
            IPagesStorageProviderV30 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV30>();

            mocks.ReplayAll();

            Host.Instance = new Host();

            Collectors.IndexDirectoryProvider = new DummyIndexDirectoryProvider();
            ProviderLoader.SetUp <IIndexDirectoryProviderV30>(typeof(DummyIndexDirectoryProvider), "");

            string messageSubject = "This is the subject of the message";
            string messageBody    = "This is the body of the message";

            DateTime    dt      = DateTime.Now;
            PageContent page    = new PageContent(new PageInfo("pagefullname", pagesStorageProvider, dt), "title", "user-test", dt, "", "content", new string[0], "");
            Message     message = new Message(1, "user-test", messageSubject, dt, messageBody);

            Assert.IsTrue(SearchClass.IndexMessage(message, page));

            List <SearchResult> results = SearchClass.Search(new SearchField[] { SearchField.Content }, "message", SearchOptions.AtLeastOneWord);

            Assert.AreEqual(1, results.Count, "Wrong result length");

            Assert.AreEqual(DocumentType.Message, results[0].DocumentType, "Wrong document type");

            MessageDocument documentMessage = results[0].Document as MessageDocument;

            Assert.AreEqual("This is the subject of the message", documentMessage.Subject, "Wrong title");
            Assert.AreEqual("This is the body of the <b class=\"searchkeyword\">message</b>", documentMessage.HighlightedBody, "Wrong content");
        }
        public void AddMessageTest()
        {
            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 messageSubject = "This is the subject of the message";
            string messageBody    = "This is the body of the message";

            DateTime    dt      = DateTime.Now;
            PageContent page    = new PageContent("pagefullname", pagesStorageProvider, dt, "title", "user-test", dt, "", "content", new string[0], "");
            Message     message = new Message(1, "user-test", messageSubject, dt, messageBody);

            Assert.IsTrue(SearchClass.IndexMessage(message, page));

            List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Content }, "message", SearchOptions.AtLeastOneWord);

            Assert.AreEqual(1, results.Count, "Wrong result length");

            Assert.AreEqual(DocumentType.Message, results[0].DocumentType, "Wrong document type");

            MessageDocument documentMessage = results[0].Document as MessageDocument;

            Assert.AreEqual("This is the subject of the message", documentMessage.Subject, "Wrong title");
            Assert.AreEqual("This is the body of the <b class=\"searchkeyword\">message</b>", documentMessage.HighlightedBody, "Wrong content");
        }