Example #1
0
        public static string GetStreetName(this IDataGenerator dataGenerator, int nullOdds = 0)
        {
            var streetName = dataGenerator.ChooseString(DataGenerationSets.StreetNames, nullOdds);

            if (streetName != null)
            {
                streetName += $" {dataGenerator.ChooseString(DataGenerationSets.StreetTypes)}";
            }

            return(streetName);
        }
Example #2
0
        public static string ChooseString(this IDataGenerator dataGenerator, Type constantsClass, int nullOdds = 0)
        {
            ArgCheck.NotNull(nameof(constantsClass), constantsClass);

            var values = constantsClass.GetFields(BindingFlags.Public | BindingFlags.Static)
                         .Where(f => f.IsPublic && f.IsStatic && f.IsLiteral)
                         .Select(f => f.GetRawConstantValue()?.ToString())
                         .ToList();

            return(dataGenerator.ChooseString(values, nullOdds));
        }
Example #3
0
        public static string GetDomainName(this IDataGenerator dataGenerator, string companyName = null, int nullOdds = 0)
        {
            if (dataGenerator.IsNull(nullOdds))
            {
                return(null);
            }

            companyName = LowercaseLettersOnly(companyName);

            if (companyName != null)
            {
                return(companyName + ".test");
            }

            return(dataGenerator.ChooseString(DataGenerationSets.DomainNames));
        }
Example #4
0
        public static string GetSocialInsuranceNumber(this IDataGenerator dataGenerator, bool formatted = false, string separator = "-", bool useDesignatedTestPrefixOfZero = false, int nullOdds = 0)
        {
            const int length = 9;

            var sin = $"{(useDesignatedTestPrefixOfZero ? "0" : dataGenerator.ChooseString("1", "2", "3", "4", "5", "6", "7", "9"))}{dataGenerator.GetNumber(7)}";

            var sum      = 0;
            var i        = 0;
            var reversed = new string(sin.Reverse().ToArray());

            while (i < length - 1)
            {
                var odd = reversed[i] * 2;
                if (odd > 9)
                {
                    odd -= 9;
                }
                sum += odd;
                if (i != (length - 2))
                {
                    sum += reversed[i + 1];
                }
                i += 2;
            }

            var checkdigit = ((((int)Math.Floor(sum / 10.0) + 1) * 10) - sum) % 10;

            sin += checkdigit;

            if (formatted)
            {
                sin = $"{sin.Substring(0, 3)}{separator}{sin.Substring(3, 3)}{separator}{sin.Substring(6, 3)}";
            }

            return(sin);
        }
Example #5
0
 public static string GetProvinceName(this IDataGenerator dataGenerator, int nullOdds = 0)
 {
     return(dataGenerator.ChooseString(DataGenerationSets.ProvinceNames, nullOdds));
 }