public void TestValidateAuthor_ContainsDigits_ReturnFalse(string value)
        {
            Assume.That(value.Length, Is.GreaterThanOrEqualTo(BookValidator.MinAuthorLength));
            Assume.That(value.Length, Is.LessThanOrEqualTo(BookValidator.MaxAuthorLength));
            var result =
                productValidatorManager.Validate(new Book(), typeof(Book).GetProperty("AuthorFirstName"), value);

            Assert.That(!result);
        }
        /// <summary>
        ///     Заполнение полей продукта
        /// </summary>
        /// <param name="input">Ввод информации полей</param>
        /// <returns></returns>
        private bool Update(string[] args)
        {
            if (!initialized)
            {
                if (args.Length == 1)
                {
                    if (!Init(args[0]))
                    {
                        responseBuffer.Append(string.Format(productTypeDoesntExist, args[0]));
                    }
                }
            }
            else
            {
                var info    = productProperties[propertyIndex];
                var isValid = validator.Validate(product, info, args[0]);
                if (isValid)
                {
                    info.SetValue(product, validator.GetLastConvertedValue());
                    if (propertyIndex + 1 < productProperties.Length)
                    {
                        propertyIndex++;
                    }
                    else
                    {
                        productCatalog.Add(product);
                        return(true);
                    }
                }
                else
                {
                    responseBuffer.Append(validator.GetLastErrorMessage());
                }
            }

            return(false);
        }
Exemple #3
0
        public void TestValidateName_ShorterThanMinLength_ReturnFalse(string value)
        {
            Assume.That(value.Length, Is.LessThan(ProductValidator.MinNameLength));
            var result = productValidatorManager.Validate(new Book(), typeof(Book).GetProperty("Name"), value);

            Assert.That(!result);
        }