lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aro...@apache.org
Subject svn commit: r462664 - in /incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test: Document/TestBinaryDocument.cs Document/TestDocument.cs Index/DocHelper.cs Index/TestSegmentReader.cs
Date Wed, 11 Oct 2006 02:25:39 GMT
Author: aroush
Date: Tue Oct 10 19:25:38 2006
New Revision: 462664

URL: http://svn.apache.org/viewvc?view=rev&rev=462664
Log:
Lucene.Net.Documents.Document.Fields() -- changed from returning an IEnumerator to IEnumerable

Modified:
    incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Document/TestBinaryDocument.cs
    incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Document/TestDocument.cs
    incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Index/DocHelper.cs
    incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Index/TestSegmentReader.cs

Modified: incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Document/TestBinaryDocument.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Document/TestBinaryDocument.cs?view=diff&rev=462664&r1=462663&r2=462664
==============================================================================
--- incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Document/TestBinaryDocument.cs (original)
+++ incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Document/TestBinaryDocument.cs Tue
Oct 10 19:25:38 2006
@@ -68,10 +68,7 @@
 			doc.Add(stringFldCompressed);
 			
 			/** test for field count */
-            System.Collections.IEnumerator iter = doc.Fields();
-            int count = 0;
-            while (iter.MoveNext()) count++;
-            Assert.AreEqual(4, count);
+            Assert.AreEqual(4, doc.GetFieldsCount());
 			
 			/** add the doc to a ram index */
 			RAMDirectory dir = new RAMDirectory();

Modified: incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Document/TestDocument.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Document/TestDocument.cs?view=diff&rev=462664&r1=462663&r2=462664
==============================================================================
--- incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Document/TestDocument.cs (original)
+++ incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Document/TestDocument.cs Tue Oct 10
19:25:38 2006
@@ -56,10 +56,7 @@
 			doc.Add(stringFld);
 			doc.Add(binaryFld);
 
-            System.Collections.IEnumerator iter = doc.Fields();
-            int count = 0;
-            while (iter.MoveNext()) count++;
-            Assert.AreEqual(2, count);
+            Assert.AreEqual(2, doc.GetFieldsCount());
 			
 			Assert.IsTrue(binaryFld.IsBinary());
 			Assert.IsTrue(binaryFld.IsStored());
@@ -74,10 +71,7 @@
 			
 			doc.Add(binaryFld2);
 			
-            iter = doc.Fields();
-            count = 0;
-            while (iter.MoveNext()) count++;
-            Assert.AreEqual(3, count);
+            Assert.AreEqual(3, doc.GetFieldsCount());
 			
 			byte[][] binaryTests = doc.GetBinaryValues("binary");
 			
@@ -92,16 +86,10 @@
 			Assert.IsTrue(binaryTest2.Equals(binaryVal2));
 			
 			doc.RemoveField("string");
-            iter = doc.Fields();
-            count = 0;
-            while (iter.MoveNext()) count++;
-            Assert.AreEqual(2, count);
+            Assert.AreEqual(2, doc.GetFieldsCount());
 			
 			doc.RemoveFields("binary");
-            iter = doc.Fields();
-            count = 0;
-            while (iter.MoveNext()) count++;
-            Assert.AreEqual(0, count);
+            Assert.AreEqual(0, doc.GetFieldsCount());
 		}
 		
 		/// <summary> Tests {@link Document#RemoveField(String)} method for a brand new Document
@@ -112,40 +100,27 @@
 		[Test]
 		public virtual void  TestRemoveForNewDocument()
 		{
-            int count;
-            System.Collections.IEnumerator iter;
-
 			Lucene.Net.Documents.Document doc = MakeDocumentWithFields();
-            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
-            Assert.AreEqual(8, count);
+            Assert.AreEqual(8, doc.GetFieldsCount());
 			doc.RemoveFields("keyword");
-            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
-            Assert.AreEqual(6, count);
+            Assert.AreEqual(6, doc.GetFieldsCount());
 			doc.RemoveFields("doesnotexists"); // removing non-existing fields is siltenlty ignored
 			doc.RemoveFields("keyword"); // removing a field more than once
-            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
-            Assert.AreEqual(6, count);
+            Assert.AreEqual(6, doc.GetFieldsCount());
 			doc.RemoveField("text");
-            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
-            Assert.AreEqual(5, count);
+            Assert.AreEqual(5, doc.GetFieldsCount());
 			doc.RemoveField("text");
-            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
-            Assert.AreEqual(4, count);
+            Assert.AreEqual(4, doc.GetFieldsCount());
 			doc.RemoveField("text");
-            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
-            Assert.AreEqual(4, count);
+            Assert.AreEqual(4, doc.GetFieldsCount());
 			doc.RemoveField("doesnotexists"); // removing non-existing fields is siltenlty ignored
-            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
-            Assert.AreEqual(4, count);
+            Assert.AreEqual(4, doc.GetFieldsCount());
 			doc.RemoveFields("unindexed");
-            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
-			Assert.AreEqual(2, count);
+			Assert.AreEqual(2, doc.GetFieldsCount());
 			doc.RemoveFields("unstored");
-            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
-            Assert.AreEqual(0, count);
+            Assert.AreEqual(0, doc.GetFieldsCount());
 			doc.RemoveFields("doesnotexists"); // removing non-existing fields is siltenlty ignored
-            iter = doc.Fields();    count = 0;  while (iter.MoveNext()) count++;
-            Assert.AreEqual(0, count);
+            Assert.AreEqual(0, doc.GetFieldsCount());
 		}
 		
         [Test]

Modified: incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Index/DocHelper.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Index/DocHelper.cs?view=diff&rev=462664&r1=462663&r2=462664
==============================================================================
--- incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Index/DocHelper.cs (original)
+++ incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Index/DocHelper.cs Tue Oct 10 19:25:38
2006
@@ -155,11 +155,10 @@
 		
 		public static int NumFields(Lucene.Net.Documents.Document doc)
 		{
-			System.Collections.IEnumerator fields = doc.Fields();
 			int result = 0;
-			while (fields.MoveNext())
+			foreach (Field field in doc.Fields())
 			{
-				System.String name = fields.Current.ToString();
+				System.String name = field.Name();
 				name += ""; // avoid compiler warning
 				result++;
 			}

Modified: incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Index/TestSegmentReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Index/TestSegmentReader.cs?view=diff&rev=462664&r1=462663&r2=462664
==============================================================================
--- incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Index/TestSegmentReader.cs (original)
+++ incubator/lucene.net/tags/Lucene.Net_1_9_1/src/Test/Index/TestSegmentReader.cs Tue Oct
10 19:25:38 2006
@@ -77,10 +77,8 @@
 			//There are 2 unstored fields on the document that are not preserved across writing
 			Assert.IsTrue(DocHelper.NumFields(result) == DocHelper.NumFields(testDoc) - DocHelper.unstored.Count);
 			
-			System.Collections.IEnumerator fields = result.Fields();
-			while (fields.MoveNext())
+			foreach (Field field in result.Fields())
 			{
-				Field field = (Field) fields.Current;
 				Assert.IsTrue(field != null);
 				Assert.IsTrue(DocHelper.nameValues.Contains(field.Name()));
 			}



Mime
View raw message