Exemple #1
0
    private void ConvertGenderToRadioButtonSelection(Person.Sex gender)
    {
        switch (gender)
        {
        case Person.Sex.MALE: _radioButton1.Checked = true;
            break;

        case Person.Sex.FEMALE: _radioButton2.Checked = true;
            break;
        }
    }
Exemple #2
0
        /// <summary>
        /// Fill out the parameters that you want to set. Everything else will be randomized.
        /// </summary>
        /// <param name="firstName">If not provided, will be random.</param>
        /// <param name="lastName">If not provided, will be random.</param>
        /// <param name="sex">If not provided, will be random.</param>
        /// <param name="age">If not provided, will be random.</param>
        /// <param name="isAlive">If not provided, will be random.</param>
        /// <param name="occupation"> --- not defined ---</param>
        /// <returns></returns>
        public Person GenerateRandomPerson(string firstName = null, string lastName = null, Person.Sex sex = Person.Sex.Randomize, int age = 0, bool?isAlive = null, string occupation = null)
        {
            Person person = new Person();

            if (sex == Person.Sex.Randomize)
            {
                sex = GetRandomSex();
            }

            person.sex = sex;

            if (firstName == null)
            {
                if (person.sex == Person.Sex.Male)
                {
                    firstName = GetRandomFromCollection(firstNamesMale);
                }
                else
                {
                    firstName = GetRandomFromCollection(firstNamesFemale);
                }
            }

            person.firstName = firstName;

            if (lastName == null)
            {
                lastName = GetRandomFromCollection(lastNames);
            }

            person.lastName = lastName;
            if (age == 0)
            {
                age = GetRandomAge();
            }
            person.age = age;

            person.isAlive = isAlive;
            if (person.isAlive == null)
            {
                person.isAlive = rndGenerator.Next(0, 2) == 1;
            }

            person.occupation = occupation;
            if (String.IsNullOrEmpty(person.occupation))
            {
                person.occupation = GetRandomFromCollection(this.occupations);
            }

            return(person);
        }
Exemple #3
0
        public Person GenerateRandomPerson(string firstName = null, string lastName = null, Person.Sex sex = Person.Sex.Randomize, int age = 0)
        {
            Person person = new Person();

            if (sex == Person.Sex.Randomize)
            {
                sex = GetRandomSex();
            }

            person.sex = sex;

            if (firstName == null)
            {
                if (person.sex == Person.Sex.Male)
                {
                    firstName = GetRandomFromIList(Person.firstNamesMale);
                }
                else
                {
                    firstName = GetRandomFromIList(Person.firstNameFemales);
                }
            }

            person.firstName = firstName;

            if (lastName == null)
            {
                lastName = GetRandomFromIList(Person.lastNames);
            }

            person.lastName = lastName;
            if (age == 0)
            {
                age = GetRandomAge();
            }
            person.age = age;
            return(person);
        }