public void BuildPredicate_WhenNoLambdaOperator_ThrowsArgumentException()
        {
            var builder = new DynamicLambdaBuilder();

            var ex = Assert.Throws<ArgumentException>(() => builder.BuildPredicate(typeof(Item), "i.Value == \"Foo\""));
            Assert.AreEqual(ExceptionMessages.DynamicLambdaBuilder_InvalidExpressionFormat, ex.Message);
        }
Exemplo n.º 2
0
        public void BuildPredicate_WhenNoLambdaOperator_ThrowsArgumentException()
        {
            var builder = new DynamicLambdaBuilder();

            var ex = Assert.Throws <ArgumentException>(() => builder.BuildPredicate(typeof(Item), "i.Value == \"Foo\""));

            Assert.AreEqual(ExceptionMessages.DynamicLambdaBuilder_InvalidExpressionFormat, ex.Message);
        }
        public void BuildPredicate_WhenPassingValidExpressionForNestedItem_GeneratesValidLambda()
        {
            var builder = new DynamicLambdaBuilder();

            var expression = builder.BuildPredicate(typeof(Store.NestedItem), "i => i.Value == \"Alpha\" || i.Value == \"Bravo\"");

            var result = Store.QueryNestedItems(expression);
            Assert.AreEqual(4, result.Length);
            Assert.AreEqual("Alpha", result[0].Value);
            Assert.AreEqual("Alpha", result[1].Value);
            Assert.AreEqual("Bravo", result[2].Value);
            Assert.AreEqual("Bravo", result[3].Value);
        }
Exemplo n.º 4
0
        public void BuildPredicate_WhenPassingValidExpressionForNestedItem_GeneratesValidLambda()
        {
            var builder = new DynamicLambdaBuilder();

            var expression = builder.BuildPredicate(typeof(Store.NestedItem), "i => i.Value == \"Alpha\" || i.Value == \"Bravo\"");

            var result = Store.QueryNestedItems(expression);

            Assert.AreEqual(4, result.Length);
            Assert.AreEqual("Alpha", result[0].Value);
            Assert.AreEqual("Alpha", result[1].Value);
            Assert.AreEqual("Bravo", result[2].Value);
            Assert.AreEqual("Bravo", result[3].Value);
        }