Esempio n. 1
0
        public void PopulatePersonProjects(Faker faker, Person person, IEnumerable <Project> projects)
        {
            if (person.Projects.Any() && faker.Random.Bool(0.3f))
            {
                person.Projects = faker.Random.ListItems(person.Projects);
            }

            foreach (var project in person.Projects.Any() ? faker.Random.ListItems(person.Projects) : Enumerable.Empty <ProjectExperience>())
            {
                project.Description   = faker.Random.Bool(0.5f) ? faker.Lorem.Sentences() : project.Description;
                project.RoleInProject = faker.Random.Bool(0.3f) ? faker.Name.JobType() : project.RoleInProject;
                project.Status        = faker.Random.Bool(0.3f) ? faker.PickRandom <PublishState>() : project.Status;
            }

            if (projects.Any())
            {
                var projectsList = projects.ToList();
                var max          = faker.Random.Bool(0.8f) ? Math.Min(projectsList.Count, 99) : projectsList.Count; // Maximal batch-size is 100 (going above this causes a HTTP 500)
                var number       = faker.Random.Int(1, max);

                foreach (var project in faker.Random.ListItems(projectsList, number))
                {
                    var projExp = ProjectExperience.Generate();
                    projExp.PersonKey  = person.RowKey;
                    projExp.ProjectKey = project.RowKey;

                    person.Projects.Add(projExp);
                }
            }
        }
Esempio n. 2
0
        public void PopulatePersonSkills(Faker faker, Person person, IEnumerable <Technology> technologies)
        {
            if (person.Skills.Any() && faker.Random.Bool(0.3f))
            {
                person.Skills = faker.Random.ListItems(person.Skills);
            }

            foreach (var skill in person.Skills.Any() ? faker.Random.ListItems(person.Skills) : Enumerable.Empty <Skill>())
            {
                skill.Level = faker.Random.Bool(0.5f) ? faker.PickRandom <SkillLevel>() : skill.Level;
            }

            if (technologies.Any())
            {
                var technologiesList = technologies.ToList();
                var max    = faker.Random.Bool(0.8f) ? Math.Min(technologiesList.Count, 99) : technologiesList.Count; // Maximal batch-size is 100 (going above this causes a HTTP 500)
                var number = faker.Random.Int(1, max);

                foreach (var technology in faker.Random.ListItems(technologiesList, number))
                {
                    var skill = Skill.Generate();
                    skill.PersonKey     = person.RowKey;
                    skill.TechnologyKey = technology.RowKey;

                    person.Skills.Add(skill);
                }
            }
        }