This project is read-only.
1
Vote

The Like operator doesn't work with Rule Compilation

description

When I run the following test I get a null reference exception. It looks like the Like operator isn't implemented for rules only for evaluators. The BuildExpression methode in the ExpressionBuilder class tries to retrieve the ExpressionType for the Like operator but it doesn't support the Like operator and that is why a null reference is returned.
[TestMethod]
public void SimpleLikeRulePersonTest()
{
    var person = new Person { Name = "Mathias" };
    var rule = new Rule("Name", Operator.Like, "Mat");
    var ruleEngine = new RuleEngine.RuleEngine();
    Func<Person, bool> ruleFunc = ruleEngine.CompileRule<Person>(rule);
    bool result = ruleFunc(person);
    Assert.AreEqual(result, true);
}
System.NullReferenceException: Object reference not set to an instance of an object.
Result StackTrace:  
at RuleEngine.ExpressionBuilder.BuildExpression[T](String propertyName, Operator ruleOperator, Object value, ParameterExpression parameterExpression) in RuleEngine\ExpressionBuilder.cs:line 34
at RuleEngine.RuleEngine.CompileRule[T](Rule rule) in RuleEngine\RuleEngine.cs:line 64
at RuleEngineTests.RuleEngineTests.SimpleRuleLoaderPersonTest2() in RuleEngineTests\RuleEngineTests.cs:line 33

comments