public virtual void TestRAMDirectorySize() { MockRAMDirectory ramDir = new MockRAMDirectory(indexDir.FullName); IndexWriter writer = new IndexWriter(ramDir, new WhitespaceAnalyzer(), false); writer.Optimize(); Assert.AreEqual(ramDir.SizeInBytes(), ramDir.GetRecomputedSizeInBytes()); SupportClass.ThreadClass[] threads = new SupportClass.ThreadClass[numThreads]; for (int i = 0; i < numThreads; i++) { int num = i; threads[i] = new AnonymousClassThread(num, writer, ramDir, this); } for (int i = 0; i < numThreads; i++) threads[i].Start(); for (int i = 0; i < numThreads; i++) threads[i].Join(); writer.Optimize(); Assert.AreEqual(ramDir.SizeInBytes(), ramDir.GetRecomputedSizeInBytes()); writer.Close(); }
public virtual void TestRAMDirectoryString() { MockRAMDirectory ramDir = new MockRAMDirectory(indexDir.FullName); // Check size Assert.AreEqual(ramDir.SizeInBytes(), ramDir.GetRecomputedSizeInBytes()); // open reader to test document count IndexReader reader = IndexReader.Open(ramDir); Assert.AreEqual(docsToAdd, reader.NumDocs()); // open search zo check if all doc's are there IndexSearcher searcher = new IndexSearcher(reader); // search for all documents for (int i = 0; i < docsToAdd; i++) { Lucene.Net.Documents.Document doc = searcher.Doc(i); Assert.IsTrue(doc.GetField("content") != null); } // cleanup reader.Close(); searcher.Close(); }