コード例 #1
0
        public void DocumentShouldNotContainMCRFieldIfThereAreNoItemsInIt()
        {
            var service = new GlobalSearchService { Logger = Mock.Create<ILogger>(), LuceneIndexFolder = Path.GetTempPath(), ServerOutputFolder = Path.GetTempPath() };

            Document doc = null;
            var indexWriter = Mock.Create<IndexWriter>();
            Mock.Arrange(() => indexWriter.AddDocument(Arg.IsAny<Document>())).DoInstead<Document>(d => doc = d);
            var fieldInfo = service.GetType().GetField("_indexWriter", BindingFlags.Static | BindingFlags.NonPublic);
            if (fieldInfo != null)
            {
                fieldInfo.SetValue(service, indexWriter);
            }

            var obj = new TestModel { Text = "text", MCR = new object[0] };
            service.InsertGlobalSearchIndex(1, ProcessSystemName, ProcessDisplayName, new[] { "Text", "MCR" }, obj);

            Assert.IsNull(doc.GetField("MCR"));
        }
コード例 #2
0
        private void InitializeService()
        {
            // This will Dispose object just after OnImportsSatisfied() and will make it useless.
            //using (service = new GlobalSearchService
            //        {
            //            LuceneIndexFolder =
            //                Path.Combine(_luceneIndexFolder, _currentDomain.FriendlyName)
            //        })
            //{
            //    service.OnImportsSatisfied();
            //}

            service = new GlobalSearchService
            {
                LuceneIndexFolder =
                    Path.Combine(_luceneIndexFolder, _currentDomain.FriendlyName)
            };

            service.OnImportsSatisfied();
        }