Ejemplo n.º 1
0
        private void ValidateAddress()
        {
            Type type = typeof(Customer);

            foreach (PropertyInfo property in type.GetProperties())
            {
                foreach (Attribute attribute in property.GetCustomAttributes())
                {
                    MinLenghtAttribute minLenghtAttribute = attribute as MinLenghtAttribute;

                    if (minLenghtAttribute == null)
                    {
                        continue;
                    }

                    if (_customer.Address.Length < minLenghtAttribute.MinLenght)
                    {
                        throw new AddressException("Address is not valid.");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Should_Be_Min_Flase(object value)
        {
            var attr = new MinLenghtAttribute(4);

            Assert.False(attr.IsValid(value));
        }