public void Should_compose_expressions_using_OR()
        {
            var criterion = new Criterion {
                FieldName = "foo",
                Values = new[] {
                    new CriterionFieldValue { RawValue = "bar" },
                    new CriterionFieldValue { RawValue = "foo", Modifier = FieldValueModifier.BooleanOr }
                }
            };

            var expression = new DefaultValueHandler().CreateExpression<MyEntity>(criterion);
            Assert.That(expression.Compile()(new MyEntity { Foo = "bar" }), Is.True);

            expression = new DefaultValueHandler().CreateExpression<MyEntity>(criterion);
            Assert.That(expression.Compile()(new MyEntity { Foo = "foo" }), Is.True);
        }
        public void Should_evaluate_complex_expression()
        {
            var criterion = new Criterion {
                FieldName = "bar",
                Values = new[] {
                    new CriterionFieldValue { RawValue = "6", Operator = FieldValueOperator.NotEqual },
                    new CriterionFieldValue { RawValue = "5", Operator = FieldValueOperator.Equal },
                    new CriterionFieldValue { RawValue = "4", Operator = FieldValueOperator.GreaterThan },
                    new CriterionFieldValue { RawValue = "0", Operator = FieldValueOperator.LessThan, Modifier = FieldValueModifier.BooleanOr}
                }
            };

            var expression = new DefaultValueHandler().CreateExpression<MyEntity>(criterion);
            Assert.That(expression.Compile()(new MyEntity { Bar = 6 }), Is.False);

            expression = new DefaultValueHandler().CreateExpression<MyEntity>(criterion);
            Assert.That(expression.Compile()(new MyEntity { Bar = 5 }), Is.True);

            expression = new DefaultValueHandler().CreateExpression<MyEntity>(criterion);
            Assert.That(expression.Compile()(new MyEntity { Bar = -1 }), Is.True);
        }
        public void Should_evaluate_greater_than_or_equal()
        {
            var criterion = new Criterion {
                FieldName = "bar",
                Values = new[] {
                    new CriterionFieldValue { RawValue = "5", Operator = FieldValueOperator.GreaterThanOrEqualTo }
                }
            };

            var expression = new DefaultValueHandler().CreateExpression<MyEntity>(criterion);
            Assert.That(expression.Compile()(new MyEntity { Bar = 4 }), Is.False);

            expression = new DefaultValueHandler().CreateExpression<MyEntity>(criterion);
            Assert.That(expression.Compile()(new MyEntity { Bar = 5 }), Is.True);
        }
        public void Should_handle_single_matching_value()
        {
            var criterion = new Criterion {
                FieldName = "foo",
                Values = new[] {
                    new CriterionFieldValue { RawValue = "bar" }
                }
            };

            var expression = new DefaultValueHandler().CreateExpression<MyEntity>(criterion);
            Assert.That(expression.Compile()(new MyEntity { Foo = "bar" }), Is.True);
        }
        public void Should_evaluate_not_equal()
        {
            var criterion = new Criterion {
                FieldName = "foo",
                Values = new[] {
                    new CriterionFieldValue { RawValue = "bar", Operator = FieldValueOperator.NotEqual }
                }
            };

            var expression = new DefaultValueHandler().CreateExpression<MyEntity>(criterion);
            Assert.That(expression.Compile()(new MyEntity { Foo = "bar" }), Is.False);

            expression = new DefaultValueHandler().CreateExpression<MyEntity>(criterion);
            Assert.That(expression.Compile()(new MyEntity { Foo = "lulz" }), Is.True);
        }