Пример #1
0
        /// <summary>
        /// Generates user names.
        /// </summary>
        /// <param name="firstName">First name is always part of the returned user name.</param>
        /// <param name="lastName">Last name may or may not be used.</param>
        /// <returns>A random user name.</returns>
        public string UserName(string firstName = null, string lastName = null)
        {
            firstName ??= Name.FirstName();
            lastName ??= Name.LastName();

            firstName = firstName.Transliterate(this.Locale);
            lastName  = lastName.Transliterate(this.Locale);

            return(Utils.Slugify(UserNameUnicode(firstName, lastName)));
        }
Пример #2
0
        /// <summary>
        /// Generates user names.
        /// </summary>
        /// <param name="firstName">Always used.</param>
        /// <param name="lastName">Sometimes used depending on randomness.</param>
        public string UserName(string firstName = null, string lastName = null)
        {
            firstName = firstName ?? Name.FirstName();
            lastName  = lastName ?? Name.LastName();

            var val = Random.Number(2);

            string result;

            if (val == 0)
            {
                result = firstName + Random.Number(99);
            }
            else if (val == 1)
            {
                result = firstName + Random.ArrayElement(new[] { ".", "_" }) + lastName;
            }
            else
            {
                result = firstName + Random.ArrayElement(new[] { ".", "_" }) + lastName + Random.Number(99);
            }

            result = result.Replace("'", "")
                     .Replace(" ", "");

            return(result);
        }
Пример #3
0
        protected virtual void Initialize(string locale)
        {
            var gname = new Name(locale);

            this.FirstName = gname.FirstName();
            this.LastName = gname.LastName();

            var ginternet = new Internet(locale);

            this.UserName = ginternet.UserName(this.FirstName, this.LastName);
            this.Email = ginternet.Email(this.UserName, this.LastName);
            this.Website = ginternet.DomainName();
            this.Avatar = ginternet.Avatar();

            var gdate = new Date() { Locale = locale };

            this.DateOfBirth = gdate.Past(50, DateTime.Now.AddYears(-20));

            var gphone = new PhoneNumbers(locale);
            this.Phone = gphone.PhoneNumber();

            var gaddress = new Address(locale);

            this.Address = new CardAddress
                {
                    Street = gaddress.StreetAddress(),
                    Suite = gaddress.SecondaryAddress(),
                    City = gaddress.City(),
                    ZipCode = gaddress.ZipCode(),
                    Geo = new CardAddress.CardGeo
                        {
                            Lat = gaddress.Latitude(),
                            Lng = gaddress.Longitude()
                        }
                };

            var gcompany = new Company(locale);

            this.Company = new CardCompany
                {
                    Name = gcompany.CompanyName(),
                    CatchPhrase = gcompany.CatchPhrase(),
                    Bs = gcompany.Bs()
                };

        }
Пример #4
0
        public void can_get_last_name_when_locale_dataset_is_split_in_male_female()
        {
            var n = new Name("ru");

            n.LastName().Should().Be("Киселева");
        }
Пример #5
0
        public void switch_locale_syntax()
        {
            var n = new Name("ru");
            n.LastName().Should().Be("Киселева");

            //switch to EN
            n["en"].LastName().Should().Be("Schultz");
        }