public void TestRightNull() { var expression = new GreaterThanExpression( Mock.Of <IExpression>(e => e.Evaluate(It.IsAny <IDictionary <string, object> >()) == (object)false), Mock.Of <IExpression>(e => e.Evaluate(It.IsAny <IDictionary <string, object> >()) == (object)null), ExpressiveOptions.None); Assert.AreEqual(null, expression.Evaluate(null)); }
public static void TestEvaluate(object lhs, object rhs, object expectedValue) { var expression = new GreaterThanExpression( Mock.Of <IExpression>(e => e.Evaluate(It.IsAny <IDictionary <string, object> >()) == lhs), Mock.Of <IExpression>(e => e.Evaluate(It.IsAny <IDictionary <string, object> >()) == rhs), new Context(ExpressiveOptions.None)); Assert.That(expression.Evaluate(null), Is.EqualTo(expectedValue)); }
public void TestIntFloatFalse() { var expression = new GreaterThanExpression( Mock.Of <IExpression>(e => e.Evaluate(It.IsAny <IDictionary <string, object> >()) == (object)1), Mock.Of <IExpression>(e => e.Evaluate(It.IsAny <IDictionary <string, object> >()) == (object)1.001), ExpressiveOptions.None); Assert.AreEqual(false, expression.Evaluate(null)); }
private object GreaterThan(object l, object r) { var scope = new Scope(); scope.SetVar("l", l); scope.SetVar("r", r); var exp = new GreaterThanExpression( new VariableExpression("l"), new VariableExpression("r") ); return(exp.Evaluate(scope, new Bindings()).AsObject()); }