public void TearDown()
 {
     this._luceneController.Dispose();
     this.DeleteIndexFolder();
     InternalSearchController.ClearInstance();
     UserController.ClearInstance();
     SearchHelper.ClearInstance();
     LuceneController.ClearInstance();
     this._luceneController = null;
 }
 private void CreateNewLuceneControllerInstance()
 {
     if (_luceneController != null)
     {
         LuceneController.ClearInstance();
         _luceneController.Dispose();
     }
     _luceneController = new LuceneControllerImpl();
     LuceneController.SetTestableInstance(_luceneController);
 }
 public void TearDown()
 {
     this.mockHostController    = null;
     Globals.DependencyProvider = null;
     this.luceneController.Dispose();
     this.DeleteIndexFolder();
     InternalSearchController.ClearInstance();
     UserController.ClearInstance();
     SearchHelper.ClearInstance();
     LuceneController.ClearInstance();
     this.luceneController      = null;
     Globals.DependencyProvider = null;
 }
Beispiel #4
0
        public void TearDown()
        {
            LuceneController.ClearInstance();
            this.luceneController.Dispose();
            this.DeleteIndexFolder();
            SearchHelper.ClearInstance();
            Globals.DependencyProvider = null;

            this.mockHostController = null;
            this.luceneController   = null;
            this.cachingProvider    = null;
            this.mockSearchHelper   = null;
            this.mockSearchQuery    = null;
        }
Beispiel #5
0
        private void CreateNewLuceneControllerInstance()
        {
            DeleteIndexFolder();
            InternalSearchController.SetTestableInstance(new InternalSearchControllerImpl());
            _internalSearchController = InternalSearchController.Instance;

            if (_luceneController != null)
            {
                LuceneController.ClearInstance();
                _luceneController.Dispose();
            }
            _luceneController = new LuceneControllerImpl();
            LuceneController.SetTestableInstance(_luceneController);
        }
Beispiel #6
0
        public void LuceneController_LockFileCanBeObtainedByOnlySingleController()
        {
            // Arrange
            const string fieldName = "content";
            var          lockFile  = Path.Combine(SearchIndexFolder, WriteLockFile);

            // Act
            var doc1 = new Document();

            doc1.Add(new NumericField(fieldName, Field.Store.YES, true).SetIntValue(1));
            this.luceneController.Add(doc1);

            // create another controller then try to access the already locked index by the first one
            var secondController = new LuceneControllerImpl();

            // Assert
            Assert.True(File.Exists(lockFile));
            Assert.Throws <SearchException>(() => secondController.Add(doc1));
        }
Beispiel #7
0
        public void GetCustomAnalyzer_WithTheProvidedAnalyzer_ReturnsTheAnalyzerCorrectly()
        {
            // Arrange
            const string HostSettingsTableName      = "HostSettings";
            const string SettingNameColumnName      = "SettingName";
            const string SettingValueColumnName     = "SettingValue";
            const string SettingIsSecureColumnName  = "SettingIsSecure";
            const string CustomAnalyzerCacheKeyName = "Search_CustomAnalyzer";
            const string CzechAnalyzerTypeName      = "Lucene.Net.Analysis.Cz.CzechAnalyzer, Lucene.Net.Contrib.Analyzers";
            var          services     = new ServiceCollection();
            var          mockData     = MockComponentProvider.CreateDataProvider();
            var          hostSettings = new DataTable(HostSettingsTableName);
            var          nameCol      = hostSettings.Columns.Add(SettingNameColumnName);

            hostSettings.Columns.Add(SettingValueColumnName);
            hostSettings.Columns.Add(SettingIsSecureColumnName);
            hostSettings.PrimaryKey = new[] { nameCol };
            hostSettings.Rows.Add(CustomAnalyzerCacheKeyName, CzechAnalyzerTypeName, true);
            mockData.Setup(c => c.GetHostSettings()).Returns(hostSettings.CreateDataReader());
            var mockedApplicationStatusInfo = new Mock <IApplicationStatusInfo>();

            mockedApplicationStatusInfo.Setup(s => s.Status).Returns(UpgradeStatus.Install);
            mockedApplicationStatusInfo.Setup(s => s.ApplicationMapPath).Returns(string.Empty);
            services.AddTransient(container => Mock.Of <IHostSettingsService>());
            services.AddTransient(container => mockedApplicationStatusInfo.Object);
            services.AddTransient(container => Mock.Of <INavigationManager>());
            Globals.DependencyProvider = services.BuildServiceProvider();
            MockComponentProvider.CreateDataCacheProvider();
            DataCache.ClearCache();
            var luceneController = new LuceneControllerImpl();

            // Act
            var analyzer = luceneController.GetCustomAnalyzer();

            // Assert
            Assert.IsInstanceOf <CzechAnalyzer>(analyzer);
        }