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));
            _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));
        }
        private void CreateNewLuceneControllerInstance()
        {
            DeleteIndexFolder();
            InternalSearchController.SetTestableInstance(new InternalSearchControllerImpl());
            _internalSearchController = InternalSearchController.Instance;

            if (_luceneController != null)
            {
                LuceneController.ClearInstance();
                _luceneController.Dispose();
            }
            _luceneController = new LuceneControllerImpl();
            LuceneController.SetTestableInstance(_luceneController);
        }
 private void CreateNewLuceneControllerInstance()
 {
     if (_luceneController != null)
     {
         LuceneController.ClearInstance();
         _luceneController.Dispose();
     }
     _luceneController = new LuceneControllerImpl();
     LuceneController.SetTestableInstance(_luceneController);
 }
 public void TearDown()
 {
     _luceneController.Dispose();
     DeleteIndexFolder();
     InternalSearchController.ClearInstance();
     UserController.ClearInstance();
     SearchHelper.ClearInstance();
     LuceneController.ClearInstance();
     _luceneController = null;
 }