lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1085295 - /incubator/lucene.net/trunk/C#/src/Test/TestSupportClass.cs
Date Fri, 25 Mar 2011 09:10:34 GMT
Author: digy
Date: Fri Mar 25 09:10:34 2011
New Revision: 1085295

URL: http://svn.apache.org/viewvc?rev=1085295&view=rev
Log:
[LUCENENET-399] [LUCENENET-374] Test_IndexReader_IsCurrent added.

Modified:
    incubator/lucene.net/trunk/C#/src/Test/TestSupportClass.cs

Modified: incubator/lucene.net/trunk/C#/src/Test/TestSupportClass.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/TestSupportClass.cs?rev=1085295&r1=1085294&r2=1085295&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/TestSupportClass.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/TestSupportClass.cs Fri Mar 25 09:10:34 2011
@@ -19,6 +19,13 @@ using System;
 using System.Collections;
 using System.Threading;
 
+using Lucene.Net.Index;
+using Lucene.Net.Search;
+using Lucene.Net.Analysis;
+using Lucene.Net.Documents;
+using Lucene.Net.Util;
+using Lucene.Net.Store;
+
 using NUnit.Framework;
 
 
@@ -953,6 +960,43 @@ namespace Lucene.Net._SupportClass
             }
         }
 
+        [Test]
+        [Description("LUCENENET-374")]
+        public void Test_IndexReader_IsCurrent()
+        {
+            RAMDirectory ramDir = new RAMDirectory();
+            IndexWriter writer = new IndexWriter(ramDir, new KeywordAnalyzer(), true, new
IndexWriter.MaxFieldLength(1000));
+            Field field = new Field("TEST", "mytest", Field.Store.YES, Field.Index.ANALYZED);
+            Document doc = new Document();
+            doc.Add(field);
+            writer.AddDocument(doc);
+
+            IndexReader reader = writer.GetReader();
+
+            writer.DeleteDocuments(new Lucene.Net.Index.Term("TEST", "mytest"));
+
+            Assert.IsFalse(reader.IsCurrent());
+
+            int resCount1 = new IndexSearcher(reader).Search(new TermQuery(new Term("TEST",
"mytest")),100).TotalHits; 
+            Assert.AreEqual(1, resCount1);
+
+            writer.Commit();
+
+            Assert.IsFalse(reader.IsCurrent());
+
+            int resCount2 = new IndexSearcher(reader).Search(new TermQuery(new Term("TEST",
"mytest")),100).TotalHits;
+            Assert.AreEqual(1, resCount2, "Reopen not invoked yet, resultCount must still
be 1.");
+
+            reader = reader.Reopen();
+            Assert.IsTrue(reader.IsCurrent());
+
+            int resCount3 = new IndexSearcher(reader).Search(new TermQuery(new Term("TEST",
"mytest")), 100).TotalHits;
+            Assert.AreEqual(0, resCount3, "After reopen, resultCount must be 0.");
+
+            reader.Close();
+            writer.Close();
+        }
+
 
         //-------------------------------------------
         int ANYPORT = 38487;



Mime
View raw message