public void Stage1_ThrowsWhenNotOnQueryField() { visitor = new BoostMethodCallTreeVisitor(1); var methodInfo = ReflectionUtility.GetMethod(() => LuceneMethods.Boost<string>(null, 0f)); // "hello".Boost(5.5) var expr = Expression.Call(methodInfo, Expression.Constant("hello"), Expression.Constant(5.5f)); TestDelegate call = () => visitor.VisitExpression(expr); Assert.That(call, Throws.InstanceOf<NotSupportedException>()); }
public void Stage1_Transform() { visitor = new BoostMethodCallTreeVisitor(1); var methodInfo = ReflectionUtility.GetMethod(() => false.Boost(0f)); var fieldExpression = new LuceneQueryFieldExpression(typeof(string), "Name"); var query = new LuceneQueryPredicateExpression(fieldExpression, Expression.Constant("foo"), BooleanClause.Occur.SHOULD); const float boostAmount = 0.5f; // (LuceneQuery[Default](+Name:"foo")).Boost(0.5f) var call = Expression.Call(methodInfo, query, Expression.Constant(boostAmount)); var result = visitor.VisitExpression(call); Assert.That(result, Is.SameAs(query)); Assert.That(((LuceneQueryPredicateExpression)result).Boost, Is.EqualTo(boostAmount)); }
public void SetUp() { visitor = new BoostMethodCallTreeVisitor(0); }