Example #1
0
        public static string RandomString(ISpecificationProperty specificationProperty)
        {
            if (specificationProperty.PropertyType != "string")
            {
                throw new ArgumentException("Specification Property " + specificationProperty.Name + " is not an string!");
            }

            if (specificationProperty.Name.ToLower().Contains("number"))
            {
                int digits = 0;

                digits = specificationProperty.Minimum == null ? 0 : ((int?)specificationProperty.Minimum).Value > 6 ? 6 : ((int?)specificationProperty.Minimum).Value;
                int minimum = Convert.ToInt32(Math.Pow(10, digits)) - 1;

                digits = ((int?)specificationProperty.Maximum).Value > 6 ? 6 : ((int?)specificationProperty.Maximum).Value;
                int maximum = Convert.ToInt32(Math.Pow(10, digits)) - 1;

                return(TemplatesHelper.RandomInt(minimum, maximum).ToString());
            }

            return(TemplatesHelper.RandomString((int)specificationProperty.Maximum));
        }