コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnIndexHitsOrderedByRelevance() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldReturnIndexHitsOrderedByRelevance()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(true);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);
            collector.Scorer = ConstantScorer(1.0f);
            collector.Collect(1);
            collector.Scorer = ConstantScorer(2.0f);
            collector.Collect(2);

            // then
            IndexHits <Document> indexHits = collector.GetIndexHits(Sort.RELEVANCE);

            assertEquals(2, indexHits.Size());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals("2", indexHits.next().get("id"));
            assertEquals(2.0f, indexHits.CurrentScore(), 0.001f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals("1", indexHits.next().get("id"));
            assertEquals(1.0f, indexHits.CurrentScore(), 0.001f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(indexHits.hasNext());
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnEmptyIteratorWhenNoHits() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal void ShouldReturnEmptyIteratorWhenNoHits()
        {
            // given
            DocValuesCollector collector  = new DocValuesCollector(false);
            IndexReaderStub    readerStub = IndexReaderWithMaxDocs(42);

            // when
            collector.DoSetNextReader(readerStub.Context);

            // then
            IndexHits <Document> indexHits = collector.GetIndexHits(null);

            assertEquals(0, indexHits.Size());
            assertEquals(Float.NaN, indexHits.CurrentScore(), 0.001f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(indexHits.hasNext());
        }