コード例 #1
0
        public virtual void TestDeleteAllIsCurrent()
        {
            // get reader
            DirectoryReader reader = Writer.GetReader();

            // assert index has a document and reader is up2date
            Assert.AreEqual(1, Writer.NumDocs, "One document should be in the index");
            Assert.IsTrue(reader.IsCurrent(), "Document added, reader should be stale ");

            // remove all documents
            Writer.DeleteAll();
            Writer.Commit();

            // assert document has been deleted (index changed), reader is stale
            Assert.AreEqual(0, Writer.NumDocs, "Document should be removed");
            Assert.IsFalse(reader.IsCurrent(), "Reader should be stale");

            reader.Dispose();
        }