public void ReflectionShouldBuildTheCorrectExpressionOnFirstLevel()
		{

			var otherCompare = ExpressionUtil.GetComparer<FirstLevel>((a) => a.Other);

			var firstLevel = new FirstLevel { First = new SecondLevel { Second = "foo" }, Other = 2 };

			var result = otherCompare(firstLevel, 2);
			Assert.IsTrue(result);
			result = otherCompare(firstLevel, 1);
			Assert.IsFalse(result);
		}
Esempio n. 2
0
        public void ReflectionShouldBuildTheCorrectExpressionOnSecondLevel()
        {
            var firstSecondCompare = ExpressionUtil.GetComparer <FirstLevel>((a) => a.First.Second);

            var firstLevel = new FirstLevel {
                First = new SecondLevel {
                    Second = "foo"
                }, Other = 2
            };

            var result = firstSecondCompare(firstLevel, "foo");

            Assert.IsTrue(result);
            result = firstSecondCompare(firstLevel, "bar");
            Assert.IsFalse(result);
        }