public void CopyFromDocumentBeforeConvertPhaseDoesNothing()
        {
            mapper       = new ReflectionScoreMapper <Sample>(typeof(Sample).GetProperty("Score"));
            sample.Score = -22f;
            queryExecutionContext.Phase = QueryExecutionPhase.Execute;

            mapper.CopyFromDocument(document, queryExecutionContext, sample);

            Assert.That(sample.Score, Is.EqualTo(-22f));
        }
        public void CopyFromDocumentBeforeConvertPhaseDoesNothing()
        {
            mapper = new ReflectionScoreMapper<Sample>(typeof(Sample).GetProperty("Score"));
            sample.Score = -22f;
            queryExecutionContext.Phase = QueryExecutionPhase.Execute;

            mapper.CopyFromDocument(document, queryExecutionContext, sample);

            Assert.That(sample.Score, Is.EqualTo(-22f));
        }
        public void CopyFromDocument()
        {
            mapper       = new ReflectionScoreMapper <Sample>(typeof(Sample).GetProperty("Score"));
            sample.Score = -22f;
            queryExecutionContext.Phase           = QueryExecutionPhase.ConvertResults;
            queryExecutionContext.CurrentScoreDoc = new ScoreDoc(0, 123f);

            mapper.CopyFromDocument(document, queryExecutionContext, sample);

            Assert.That(sample.Score, Is.EqualTo(queryExecutionContext.CurrentScoreDoc.Score));
        }
        public void CopyFromDocument()
        {
            mapper = new ReflectionScoreMapper<Sample>(typeof(Sample).GetProperty("Score"));
            sample.Score = -22f;
            queryExecutionContext.Phase = QueryExecutionPhase.ConvertResults;
            queryExecutionContext.CurrentScoreDoc = new ScoreDoc(0, 123f);

            mapper.CopyFromDocument(document, queryExecutionContext, sample);

            Assert.That(sample.Score, Is.EqualTo(queryExecutionContext.CurrentScoreDoc.Score));
        }
예제 #5
0
        /// <summary>
        /// Defines a property to be set with the value of <see cref="ScoreDoc.Score"/>
        /// when retrieving query results. See <seealso cref="QueryScoreAttribute"/>.
        /// </summary>
        public void Score(Expression <Func <T, object> > expression)
        {
            var propInfo = GetMemberInfo <PropertyInfo>(expression.Body);

            scoreMapper = new ReflectionScoreMapper <T>(propInfo);
        }