예제 #1
0
        private bool CheckProperty(object actual, int i, Type type)
        {
            bool passed = true;

            string label        = this.GetLabel(i);
            string propertyName = NameComparer.NormalizeName(label);

            PropertyInfo pi = ValueGetter.GetPropertyInfo(type, propertyName);

            if (pi != null)
            {
                object actualValue   = pi.GetValue(actual, null);
                object expectedValue = ValueParser.ParseValue(this.GetValue(i), pi.PropertyType);

                if (!object.Equals(actualValue, expectedValue))
                {
                    this.values[i] = string.Format("{0} (was {1})", expectedValue, actualValue);
                    passed         = false;
                }
            }
            else
            {
                this.values[i] = string.Format("{0} (unknown)", this.GetValue(i));
                passed         = false;
            }

            return(passed);
        }
예제 #2
0
        internal static PropertyInfoValueSetter GetPropertyInfoValueSetter(object target, string normalizedName)
        {
            PropertyInfo property = ValueGetter.GetPropertyInfo(target.GetType(), normalizedName);

            if (property != null && PropertyCanSetValue(property))
            {
                return(new PropertyInfoValueSetter(target, property));
            }

            return(null);
        }
예제 #3
0
파일: Grid.cs 프로젝트: gzlive/behaven
        /// <summary>
        /// Gets the property info specified by the header.
        /// </summary>
        /// <param name="type">The type containing the property.</param>
        /// <param name="header">The header.</param>
        /// <returns>The property info.</returns>
        private PropertyInfo GetPropertyInfo(Type type, string header)
        {
            string propertyName = NameComparer.NormalizeName(header);

            return(ValueGetter.GetPropertyInfo(type, propertyName));
        }