public void SetupOnlyOnce()
 {
     _deepNodeFinder = GetNodeProvider();
     _indexMgr = InitializeIndex(_deepNodeFinder);
 }
        private LuceneIndexMgr InitializeIndex(INodesForIndexingProvider deepNodeFinder)
        {
            LuceneIndexMgr result = new LuceneIndexMgr();
            indexMrgsNeedingCleanupAtTearDown.Add(result);

            bool isInitializationCompletedHandlerCalled = false;
            result.IndexingCompleted += delegate { isInitializationCompletedHandlerCalled = true; };

            Assert.IsFalse(result.IsInitialized, "TEST SANITY: IsInitialized should be false");

            result.Initialize("en", deepNodeFinder);

            Stopwatch timer = new Stopwatch();
            timer.Start();

            while (result.IsIndexing)
            {
                if (timer.ElapsedMilliseconds > 120000)
                    throw new Exception("It's taken longer than 120 seconds to initialize");
                Thread.Sleep(500);
            }

            Thread.Sleep(1000);

            Assert.IsTrue(isInitializationCompletedHandlerCalled,
                          "isInitializationCompletedHandlerCalled was false but should be true");
            Assert.IsTrue(result.IsInitialized, "IsInitialized was false but should be true");

            return result;
        }