Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyRuleBase"/> class.
        /// </summary>
        /// <param name="propertyExpression">Property Expression for property.</param>
        /// <param name="name">Name of Rule.</param>
        protected PropertyRuleBase(LambdaExpression propertyExpression, string name)
            : base(name)
        {
            Check.IsNotNull(propertyExpression, "Property Expression is required");

            PropertyExpression = propertyExpression;
            PropertyChain      = PropertyChain.FromLambdaExpression(propertyExpression);
            AddAttribute("PropertyChain", PropertyChain);
        }
Example #2
0
        public void FromLambdaExpression_GivenLambdaExpression_ReturnsPropertyChainCorretly()
        {
            // Setup
            Expression <Func <object> > propertyExpression = () => this.MyProperty.Length;

            // Exercise
            var propertyChain = PropertyChain.FromLambdaExpression(propertyExpression);
            var str           = propertyChain.ToString();

            // Verify
            Assert.AreEqual("MyProperty" + "." + "Length", str);
        }