Ejemplo n.º 1
0
        public static string GetPhoneNumber(this IDataGenerator dataGenerator, bool formatted = false, string prefix = "+1")
        {
            if (formatted)
            {
                return($"{prefix} ({dataGenerator.GetNumber(3)}) {dataGenerator.GetNumber(3)}-{dataGenerator.GetNumber(4, canStartWithZero: true)}");
            }

            return($"{prefix}{dataGenerator.GetNumber(3)}{dataGenerator.GetNumber(3)}{dataGenerator.GetNumber(4, canStartWithZero: true)}");
        }
Ejemplo n.º 2
0
        public static string GetSocialSecurityNumber(this IDataGenerator dataGenerator, bool formatted = false, int nullOdds = 0)
        {
            if (formatted)
            {
                return(dataGenerator.GetString("000-00-0000"));
            }

            return(dataGenerator.GetNumber(9));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 public static string GetZipCode(this IDataGenerator dataGenerator, int nullOdds = 0)
 {
     return(dataGenerator.GetNumber(5));
 }