[ 
https://issues.apache.org/jira/browse/LUCENENET-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12523697
 ] 

Neal Granroth commented on LUCENENET-97:
----------------------------------------

The problem description lists the specific failure.
However, to be very specific, here is an NUnit test case illustrating the 
problem: 


       [Test]
                public virtual void  TestIterator2()
                {
                        RAMDirectory directory = new RAMDirectory();
                        
                        IndexWriter writer = new IndexWriter(directory, new 
WhitespaceAnalyzer(), true);
                        Lucene.Net.Documents.Document doc = new 
Lucene.Net.Documents.Document();
                        doc.Add(new Field("field", "iterator test doc 1", 
Field.Store.YES, Field.Index.TOKENIZED));
                        writer.AddDocument(doc);
                        
                        doc = new Lucene.Net.Documents.Document();
                        doc.Add(new Field("field", "iterator test doc 2", 
Field.Store.YES, Field.Index.TOKENIZED));
                        writer.AddDocument(doc);
                        
                        writer.Close();
                        
                        IndexSearcher searcher = new IndexSearcher(directory);
                        Hits hits = searcher.Search(new TermQuery(new 
Term("field", "iterator")));
                        
                        // ..................                   

                        HitIterator iterator = (HitIterator) hits.Iterator();
                        Assert.AreEqual(2, iterator.Length());
                        
                        // ..................                   

                        iterator.MoveNext(); // position to 1st hit
                        iterator.MoveNext(); // position to 2nd hit
                        Assert.AreEqual("iterator test doc 2",
                                
((Hit)iterator.Current).GetDocument().Get("field"));
                                
                        // ..................                   
                        
                        HitIterator iterator2 = (HitIterator) hits.Iterator();

                        Hit hit = (Hit) iterator2.Current;
                        Assert.AreEqual("iterator test doc 1", 
hit.Get("field"));
                        
                        // Verify that "Current" does not move, when MoveNext 
is not called.
                        
                        Hit hitAgain = (Hit) iterator2.Current;
                        Assert.AreEqual("iterator test doc 1", 
hitAgain.Get("field"));
                        
                }


> HitIterator does not correctly implement System.Collections.IEnumerator
> -----------------------------------------------------------------------
>
>                 Key: LUCENENET-97
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-97
>             Project: Lucene.Net
>          Issue Type: Bug
>         Environment: .NET
>            Reporter: Neal Granroth
>
> method MoveNext() is supposed to increment the position within the list; it 
> does not.
> method Current() is supposed to return the object at the current position, 
> but not change the position within the list.
> It incorrectly moves to the next position.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to