Exemple #1
0
        public void Test_Indexed_Persons_Sorted_Paging_By_Index()
        {
            const int ITEMS_COUNT = 100;

            const string INDEX_NAME_NAME = "name";

            // definizione indice su entità Person
            var persons = new Index <Person>(
                new IndexMaker <Person, string>(INDEX_NAME_NAME, p => p.FirstName)
                );

            // Generiamo ITEMS_COUNT entità casuali
            var fakerRandomizer  = new Bogus.Randomizer();
            var fakerNameDataset = new Bogus.DataSets.Name("en");

            for (var i = 0; i < ITEMS_COUNT; i++)
            {
                persons.Add(new Person(
                                fakerNameDataset.FirstName(),
                                fakerNameDataset.LastName(),
                                fakerRandomizer.Int(1900, 2000) * 10000 + fakerRandomizer.Int(1, 12) * 100 + fakerRandomizer.Int(1, 31)));
            }

            // Enumeriamo gli ultimi 10 item ordinati desc per l'indice creato
            const int PAGE_SIZE = ITEMS_COUNT / 10;

            _output.WriteLine($"Ultimi {PAGE_SIZE} item in ordine inverso:\n");

            var lastPageByName = persons[INDEX_NAME_NAME].AsEnumerable().Skip(ITEMS_COUNT - PAGE_SIZE).Take(PAGE_SIZE).Reverse();

            foreach (var p in lastPageByName)
            {
                _output.WriteLine($"{p.FirstName}");
            }
        }
        public RequestDto GetRequest()
        {
            var random = new Bogus.Randomizer();
            var lorem  = new Bogus.DataSets.Lorem();

            var subRequest = new Faker <SubRequestDto>()
                             .RuleFor(first => first.Name, f => lorem.Text())
                             .RuleFor(first => first.ChildID, f => random.Number(1990, 2030))
                             .RuleFor(first => first.DateOfBirth, f => f.Date.Recent(100));

            var requestDto = new RequestDto()
            {
                Year           = random.Number(1990, 2030),
                Denomination1  = lorem.Text(),
                Denomination2  = lorem.Text(),
                MaritalStatus  = random.Word(),
                SubRequests    = subRequest.Generate(2),
                Income         = (decimal)random.Number(10000, 2564789),
                QualifiedProp  = (decimal)random.Number(10000, 2564789),
                QualifiedProp2 = (decimal)random.Number(10000, 2564789),
                SomeProp       = (decimal)random.Number(10000, 2564789),
                SomeProp2      = (decimal)random.Number(10000, 2564789),
                SomeProp3      = (decimal)random.Number(10000, 2564789),
                Shortname      = random.Word(),
                SomeProp22     = random.Word(),
            };

            return(requestDto);
        }
Exemple #3
0
        Generate(int siteId, int count)
        {
            var branches = await _siteService.GetAllBranches(true);

            var programs = await _siteService.GetProgramList();

            var schools = await _schoolService.GetSchoolsAsync();

            var testUsers = new Faker <Domain.Model.User>()
                            .Rules((f, u) =>
            {
                var branch  = f.PickRandom(branches);
                var program = f.PickRandom(programs);
                u.BranchId  = branch.Id;
                if (f.Random.Bool())
                {
                    u.Email = f.Person.Email;
                }
                u.FirstName = f.Person.FirstName;
                u.LastName  = f.Person.LastName;
                if (f.Random.Bool())
                {
                    u.PhoneNumber = f.Phone.PhoneNumber("###-###-####");
                }
                u.PostalCode = f.Address.ZipCode();
                u.ProgramId  = program.Id;
                u.SiteId     = siteId;
                u.SystemId   = branch.SystemId;
                u.Username   = f.Person.UserName;
                if (program.AskAge && (f.Random.Bool() || program.AgeRequired))
                {
                    u.Age = f.Random.Number(0, 104);
                }
                if (program.AskSchool && (f.Random.Bool() || program.SchoolRequired))
                {
                    var school = f.PickRandom(schools);
                    u.SchoolId = school.Id;
                }
            });

            var rand  = new Bogus.Randomizer();
            var users = new List <GeneratedUser>();

            for (int i = 0; i < count; i++)
            {
                var user = testUsers.Generate();

                users.Add(new GeneratedUser
                {
                    User     = user,
                    Password = "******"
                });
            }
            return(users);
        }
Exemple #4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (GameData.coworker)
        {
            rend.enabled = true;
        }
        if (m_LastPressTime + m_PressDelay < Time.unscaledTime && GameData.coworker)
        {
            var x = Instantiate(box, new Vector3(-15f, 1.8f, 0f), Quaternion.identity);

            m_LastPressTime = Time.unscaledTime;

            boxes.Add(x);
        }
        if (boxes != null)
        {
            foreach (var b in boxes)
            {
                if (b.transform.position.x < -4f)
                {
                    b.transform.position += new Vector3(0.05f, 0f, 0f);
                    if (b.transform.position.x > -5f && b.transform.position.x < -4.98f)
                    {
                        Debug.Log("try");
                        Co.SetTrigger("DropOff");
                    }
                }
                else if (b.transform.position.x < -1.5)
                {
                    b.transform.position += new Vector3(0.04f, 0f, 0f);
                }
                else
                {
                    var random = new Bogus.Randomizer();
                    int num    = random.Number(1, 2);
                    if (num == 1)
                    {
                        b.transform.position += new Vector3(0f, 0.04f, 0f);
                    }
                    else
                    {
                        b.transform.position += new Vector3(0f, 0.04f, 0f);
                    }
                }
                if (b.transform.position.y < -1 || b.transform.position.y > 4)
                {
                    Destroy(b);
                    var index = boxes.IndexOf(b);

                    boxes.RemoveAt(index);
                    break;
                }
            }
        }
    }
        public Result GetResult()
        {
            var random = new Bogus.Randomizer();

            return(new Result()
            {
                Prop1 = (decimal)random.Number(10000, 2564789),
                Prop2 = (decimal)random.Number(10000, 2564789),
                Prop3 = (decimal)random.Number(10000, 2564789),
                Prop4 = (decimal)random.Number(10000, 2564789),
                Prop5 = (decimal)random.Number(10000, 2564789),
            });
        }
Exemple #6
0
    public void GeneratePackage()
    {
        //assigns random data to the box the player must check matches screen
        var random = new Bogus.Randomizer();
        var data   = new Bogus.DataSets.Commerce("en");
        var local  = new Bogus.DataSets.Address("en");
        var user   = new Bogus.DataSets.Name("en");

        zip     = local.ZipCode();
        address = local.StreetAddress();
        ID      = random.Number(1, 9999);
        item    = data.Product();
        name    = user.FullName();
    }
Exemple #7
0
    // Start is called before the first frame update
    public void Start()
    {
        //When initialized must determine what game flags are so certain types of boxes can be spawned

        box = Small_box;
        var random = new Bogus.Randomizer();
        int num    = random.Number(1, 2);

        if (num == 1 && !coworker)
        {
            pos = new Vector3(9.5f, 9f, 0f);
        }
        else if (num == 2 && !coworker)
        {
            pos = new Vector3(11.5f, 9f, 0f);
        }
        else if (coworker)
        {
            //if the coworker is missing spawn a box on his line
            pos = new Vector3(-15f, 1.8f, 0f);
        }
        num = random.Number(1, 2);
        GeneratePackage();

        GenerateAnswer(num);
        //pick a random box sprite to look as and instantiate
        num = random.Number(1, 4);
        switch (num)
        {
        case 1:
            box.GetComponent <SpriteRenderer>().sprite = b;
            break;

        case 2:
            box.GetComponent <SpriteRenderer>().sprite = b1;
            break;

        case 3:
            box.GetComponent <SpriteRenderer>().sprite = b2;
            break;

        case 4:
            box.GetComponent <SpriteRenderer>().sprite = b3;
            break;
        }
        box = Instantiate(box, pos, Quaternion.identity);
        box.transform.parent = transform;
    }
Exemple #8
0
        public Employee()
        {
            var person = new Person();

            UserName    = person.UserName;
            FirstName   = person.FirstName;
            LastName    = person.LastName;
            Email       = person.Email;
            Phone       = person.Phone;
            DateOfBirth = person.DateOfBirth;

            var bogusRandom = new Bogus.Randomizer();
            var bogusDate   = new Bogus.DataSets.Date();

            DateHired       = bogusDate.Between(DateTime.Today.AddYears(-5), DateTime.Today);
            DateContractEnd = bogusDate.Between(DateTime.Today, DateTime.Today.AddYears(-5));
            ChildrenCount   = bogusRandom.Int(0, 6);
            ShoeSize        = bogusRandom.Double(7, 12);
            ChangeInPocket  = bogusRandom.Double(0, 5);
            CarValue        = bogusRandom.Double(500, 40000);
        }
Exemple #9
0
    public void GenerateAnswer(int num)
    {
        //if num is 1 generate 1 false answer if not set the answer to the values already asssigned
        var random = new Bogus.Randomizer();
        var data   = new Bogus.DataSets.Commerce("en");
        var local  = new Bogus.DataSets.Address("en");
        var user   = new Bogus.DataSets.Name("en");

        reject   = false;
        zipA     = zip;
        addressA = address;
        nameA    = name;
        IDA      = ID;
        itemA    = item;
        if (num == 1)
        {
            reject = true;
            int numb = random.Number(1, 5);
            if (numb == 1)
            {
                zipA = zip = local.ZipCode();
            }
            if (numb == 2)
            {
                address = local.StreetAddress();
            }
            if (numb == 3)
            {
                ID = random.Number(1, 9999);
            }
            if (numb == 4)
            {
                item = data.Product();
            }
            else
            {
                name = user.FullName();
            }
        }
    }
        protected override void Seed(ApplicationDbContext context)
        {
            base.Seed(context);
            int movieCount  = 20;
            int crewCount   = 40; //weight actors 0.8 directors 0.2
            int reviewCount = 20;
            int userCount   = 30;



            #region UserRoles

            const string adminRoleName = "Admin";
            const string userRoleName  = "UserNormal";

            var roleStore   = new RoleStore <IdentityRole>(context);
            var roleManager = new RoleManager <IdentityRole>(roleStore);

            var adminRole = new IdentityRole {
                Name = adminRoleName
            };
            var userRole = new IdentityRole {
                Name = userRoleName
            };

            roleManager.Create(adminRole);
            roleManager.Create(userRole);


            #endregion

            #region Users

            var store   = new UserStore <ApplicationUser>(context);
            var manager = new UserManager <ApplicationUser>(store);

            #region Admin user account

            var admin = new ApplicationUser()
            {
                Id             = Guid.NewGuid().ToString(),
                UserName       = "******",
                Email          = "*****@*****.**",
                EmailConfirmed = true
            };


            var checkAdminUser = manager.Create(admin, "pass123");
            if (checkAdminUser.Succeeded)
            {
                manager.AddToRole(admin.Id, adminRoleName);
            }
            else
            {
                var errors = checkAdminUser.Errors;
                errors.ForEach(e => Debug.WriteLine(e));
            }


            #endregion

            var users = new Faker <ApplicationUser>()
                        .Rules((f, u) =>
            {
                var userEmail    = f.Internet.Email();
                u.Id             = Guid.NewGuid().ToString();
                u.AvatarUri      = f.Internet.Avatar();
                u.DisplayName    = f.Name.FullName();
                u.UserName       = userEmail;
                u.Email          = userEmail;
                u.EmailConfirmed = true;
            })
                        .Generate(userCount);

            users.ForEach(u =>
            {
                var checkUser = manager.Create(u, "pass123");

                if (checkUser.Succeeded)
                {
                    manager.AddToRole(u.Id, userRoleName);
                }
                else
                {
                    checkUser.Errors.ForEach(e => Debug.WriteLine(e));
                }
            });


            #endregion

            #region Gernes

            string[] genreNames =
            {
                "Action", "Action", "Adventure", "Comedy", "Crime", "Drama", "Fantasy", "Horror", "Romance", "Science fiction",
                "Thriller"
            };
            context.Genres.AddRange(genreNames.Select(genre => new Genre()
            {
                Title = genre
            }));

            #endregion

            #region Movies

            var random          = new Bogus.Randomizer();
            var reviewGenerator = new Faker <Review>()
                                  .Rules((f, r) =>
            {
                r.AuthorId  = f.PickRandom(users.Select(u => u.Id));
                r.Title     = f.Lorem.Sentence();
                r.Body      = f.Lorem.Sentences();
                r.CreatedOn = f.Date.Past();
                r.Rating    = f.Random.Float(0, 10);
            });

            var movies = new Faker <Movie>()
                         .Rules((f, m) =>
            {
                m.Title       = f.Hacker.Adjective() + " " + f.Hacker.Noun();
                m.Year        = f.Random.Int(2000, 2018);
                m.Length      = f.Random.Int(60, 180);
                m.Rating      = f.Random.Float(0f, 10f);
                m.Image       = f.Image.PicsumUrl(320, 320);
                m.Description = f.Lorem.Sentences();
                m.Reviews     = reviewGenerator.Generate(random.Int(3, 8));
                m.Comments    = Get20Comments();
                m.Reviews.ForEach(r => r.Comments = Get20Comments());
            })
                         .Generate(movieCount);

            //movies = Enumerable.Range(0, movieCount).Zip(movies, (i, m) =>
            //{
            //  m.Reviews.ForEach(r => r.MovieId = i);
            //  m.Id = i;
            //  return m;
            //}).ToList();

            #endregion

            #region FilmCrewMember
            var crew = new Faker <FilmCrewMember>()
                       .Rules((f, c) =>
            {
                c.Bio      = f.Lorem.Sentences();
                c.DoB      = f.Date.Past(60, new DateTime(1990, 2, 15));
                c.ImageUri = f.Internet.Avatar();
                c.Name     = f.Name.FullName();
                c.Role     = (MovieRole)f.Random.WeightedRandom(new int[] { 0, 1 }, new float[]
                {
                    0.8f, 0.2f
                });
                c.Comments = Get20Comments();
            })
                       .Generate(crewCount);


            var moviesArr = movies.ToList();
            crew.ForEach(c => c.Movies = random.ListItems <Movie>(moviesArr, random.Number(3, 10)));

            context.FilmCrewMembers.AddRange(crew);
            #endregion

            List <Comment> Get20Comments()
            {
                var comments = new Faker <Comment>()
                               .Rules((f, c) =>
                {
                    c.AuthorId    = f.PickRandom(users.Select(u => u.Id));
                    c.CommentBody = f.Lorem.Sentences();
                    c.CreatedOn   = f.Date.Past();
                })
                               .Generate(20);
                var parentCommentsCount = random.Int(8, 13);
                var parentComments      = comments.Take(parentCommentsCount).ToArray();
                var childrenComments    = comments.Skip(parentCommentsCount).ToArray();

                childrenComments.ForEach(c => c.CommentParentId = random.Number(0, 2));


                return(parentComments.Concat(childrenComments).ToList());
            }

            context.Users.ForEach(u => u.EmailConfirmed = true);
            context.SaveChanges();
        }
        protected virtual void Initialize(string locale)
        {
            var PhoneType       = new[] { "Home", "Office", "Private", "Personal" };
            var TitleOfCourtesy = new[] { "Dr", "Miss", "Mr", "Mrs", "Ms" };
            var PositionTitle   = new[] { "Head", "Developer", "Manager", "Admin", "Marketing" };
            var UserRole        = new[] { "Administrators", "Users" };

            var lorem  = new Bogus.DataSets.Lorem();
            var random = new Bogus.Randomizer();

            var bDeptName = new Bogus.DataSets.Name(locale);

            Title  = bDeptName.JobTitle();
            Office = bDeptName.JobType();

            var gaddress = new Address(locale);

            this.Address = new CAddress
            {
                Street  = gaddress.StreetAddress(),
                Suite   = gaddress.SecondaryAddress(),
                City    = gaddress.City(),
                ZipCode = gaddress.ZipCode(),
            };
            var cSpouseName = new Name(locale);
            var rValue      = new Random();
            var cPerson     = new Person(locale);

            this.Person = new Contact
            {
                CPerson = new Contact.Person
                {
                    FirstName   = cPerson.FirstName,
                    LastName    = cPerson.LastName,
                    NickName    = cPerson.UserName,
                    DateOfBirth = cPerson.DateOfBirth,
                    Email       = cPerson.Email,
                    Phone       = cPerson.Phone,
                    Website     = cPerson.Website,
                    SpouseName  = cSpouseName.FindName()
                },
            };
            this.UserRole = UserRole[rValue.Next(UserRole.Length)];
            var cManager = new Person(locale);

            this.Manager = new Contact
            {
                CPerson = new Contact.Person
                {
                    FirstName   = cManager.FirstName,
                    LastName    = cManager.LastName,
                    NickName    = cManager.UserName,
                    DateOfBirth = cManager.DateOfBirth,
                    Email       = cManager.Email,
                    Phone       = cManager.Phone,
                    SpouseName  = cSpouseName.FindName(),
                    Website     = cManager.Website
                },
                //TitleOfCourtesy = TitleOfCourtesy[rValue.Next(TitleOfCourtesy.Length)]
            };

            this.Positions = new Position
            {
                Title = PositionTitle[rValue.Next(PositionTitle.Length)]
            };
        }
Exemple #12
0
 void OnTriggerEnter2D(Collider2D c)
 {
     //when the collider of the stamp triggers on a package stamp with a random corresponding stamp
     if (c.GetComponent <BoxCollider2D>().tag == "Package" && isgrabbed)
     {
         boxRend = c.transform.Find("stamped").gameObject.GetComponent <SpriteRenderer>();
         var x = c.GetComponent <BoxCollider2D>().transform.parent.gameObject;
         data = x.GetComponent("PackageData") as PackageData;
         var random = new Bogus.Randomizer();
         int num    = random.Number(1, 3);
         if (approved)
         {
             if (num == 1)
             {
                 boxRend.sprite = a1;
             }
             else if (num == 2)
             {
                 boxRend.sprite = a2;
             }
             else
             {
                 boxRend.sprite = a3;
             }
             snd.Play();
         }
         else
         {
             if (num == 1)
             {
                 boxRend.sprite = r1;
             }
             else if (num == 2)
             {
                 boxRend.sprite = r2;
             }
             else
             {
                 boxRend.sprite = r3;
             }
             snd.Play();
         }
         boxRend.enabled = true;
         data.accepted   = approved;
     }
     if (m_LastPressTime + m_PressDelay < Time.unscaledTime)
     {
         //if stamp triggers witht the stamp box change the stamp to red or green
         m_LastPressTime = Time.unscaledTime;
         if (c.gameObject.name == "Reject Pad" && isgrabbed)
         {
             rend.sprite = red;
             approved    = false;
             snd.Play();
         }
         else if (c.gameObject.name == "Approve Pad" && isgrabbed)
         {
             rend.sprite = green;
             approved    = true;
             snd.Play();
         }
     }
 }
Exemple #13
0
        public void Test_Indexed_Persons_Find_By_Index()
        {
            const int ITEMS_COUNT = 1000000;

            const string INDEX_NAME_YEAR  = "year";
            const string INDEX_NAME_MONTH = "month";
            const string INDEX_NAME_DAY   = "day";
            const string INDEX_NAME_NAME  = "name";

            // Lookup
            string[] months =
            {
                "Jan",
                "Feb",
                "Mar",
                "Apr",
                "May",
                "Jun",
                "Jul",
                "Aug",
                "Sep",
                "Oct",
                "Nov",
                "Dec"
            };

            // definizione indici su entità Person
            var persons = new Index <Sample_Entities.Person>(
                new IndexMaker <Person, string>(INDEX_NAME_NAME, p => p.FirstName),
                new IndexMaker <Person, int>(INDEX_NAME_YEAR, p => p.Date / 10000),
                new IndexMaker <Person, int>(INDEX_NAME_DAY, p => p.Date % 100),
                new IndexMaker <Person, string>(INDEX_NAME_MONTH, p => months[p.Date / 100 % 100 - 1])
                );

            // Generiamo ITEMS_COUNT entità casuali
            var fakerRandomizer  = new Bogus.Randomizer();
            var fakerNameDataset = new Bogus.DataSets.Name("en");

            for (var i = 0; i < ITEMS_COUNT; i++)
            {
                persons.Add(new Person(
                                fakerNameDataset.FirstName(),
                                fakerNameDataset.LastName(),
                                fakerRandomizer.Int(1900, 2000) * 10000 + fakerRandomizer.Int(1, 12) * 100 + fakerRandomizer.Int(1, 31)));
            }

            var sw = new Stopwatch();

            sw.Reset();

            // Ricerca su indice year

            const int YEAR_TO_SEARCH_FOR = 1971;

            if (persons[INDEX_NAME_YEAR][YEAR_TO_SEARCH_FOR].Any())
            {
                _output.WriteLine($"Indice '{INDEX_NAME_YEAR}', ricerca su valore {YEAR_TO_SEARCH_FOR}, trovati {persons[INDEX_NAME_YEAR][YEAR_TO_SEARCH_FOR].Count} item");
            }
            else
            {
                _output.WriteLine("Nessuno.");
            }

            _output.WriteLine($"Tempo impiegato: {sw.ElapsedMilliseconds} msec\n");

            sw.Restart();

            // Ricerca su indice month

            const string MONTH_TO_SEARCH_FOR = "Nov";

            if (persons[INDEX_NAME_MONTH][MONTH_TO_SEARCH_FOR].Any())
            {
                _output.WriteLine($"Indice '{INDEX_NAME_MONTH}', ricerca su valore {MONTH_TO_SEARCH_FOR}, trovati {persons[INDEX_NAME_MONTH][MONTH_TO_SEARCH_FOR].Count} item");
            }
            else
            {
                _output.WriteLine("Nessuno.");
            }

            _output.WriteLine($"Tempo impiegato: {sw.ElapsedMilliseconds} msec\n");

            // Ricerca su indice day

            sw.Restart();

            const int DAY_TO_SEARCH_FOR = 17;

            if (persons[INDEX_NAME_DAY][DAY_TO_SEARCH_FOR].Any())
            {
                _output.WriteLine($"Indice '{INDEX_NAME_DAY}', ricerca su valore {DAY_TO_SEARCH_FOR}, trovati {persons[INDEX_NAME_DAY][DAY_TO_SEARCH_FOR].Count} item");
            }
            else
            {
                _output.WriteLine("Nessuno.");
            }

            _output.WriteLine($"Tempo impiegato: {sw.ElapsedMilliseconds} msec\n");

            // Ricerca su indice name

            sw.Restart();

            const string NAME_TO_SEARCH_FOR = "Lawrence";

            if (persons[INDEX_NAME_NAME][NAME_TO_SEARCH_FOR].Any())
            {
                _output.WriteLine($"Indice '{INDEX_NAME_NAME}', ricerca su valore {NAME_TO_SEARCH_FOR}, trovati {persons[INDEX_NAME_NAME][NAME_TO_SEARCH_FOR].Count} item");
            }
            else
            {
                _output.WriteLine("Nessuno.");
            }

            _output.WriteLine($"Tempo impiegato: {sw.ElapsedMilliseconds} msec\n");
        }
Exemple #14
0
        static void Main(string[] args)
        {
            Randomizer.Seed = new Random(3897234);
            var random     = new Bogus.Randomizer();
            var guildNames = new[] { null, "Guild A", "Guild B", "Guild C", "Guild D", "Guild E" };
            var faction    = new [] { "Horde", "Alliance", "Undefined" };
            var race       = new[]
            {
                "Human", "Kaldorei", "Gnome", "Dwarf", "Worgen", "Orc", "Tauren",
                "Forsaken", "Sindorei", "Goblin", "Pandaren"
            };

            var isActive = new[] { true, false };

            var dateInfo = new Faker <DateInfo>()
                           .StrictMode(true)
                           .RuleFor(x => x.CreatedDate, f => f.Date.Recent())
                           .RuleFor(x => x.UpdatedDate, f => f.Date.Recent());

            var story = new Faker <Story>()
                        .StrictMode(true)
                        .RuleFor(x => x.Body, f => f.Lorem.Paragraphs(3))
                        .RuleFor(x => x.Id, f => f.IndexFaker)
                        .RuleFor(x => x.Title, f => f.Lorem.Sentence())
                        .RuleFor(x => x.DateInfo, f => dateInfo.Generate());

            var picture = new Faker <Picture>()
                          .StrictMode(true)
                          .RuleFor(x => x.Id, f => f.IndexFaker)
                          .RuleFor(x => x.Caption, f => f.Lorem.Sentence())
                          .RuleFor(x => x.Url, f => f.Internet.Url());

            var guild = new Faker <Guild>()
                        .StrictMode(true)
                        .RuleFor(x => x.Name, f => f.PickRandom(guildNames))
                        .RuleFor(x => x.Description, f => f.Lorem.Paragraphs(3));

            var character = new Faker <Character>()
                            .StrictMode(true)
                            .RuleFor(x => x.Id, f => f.IndexFaker)
                            .RuleFor(x => x.FirstName, f => f.Name.FirstName())
                            .RuleFor(x => x.LastName, f => f.Name.LastName())
                            .RuleFor(x => x.EyeColor, f => f.Commerce.Color())
                            .RuleFor(x => x.EyeColor, f => f.Commerce.Color())
                            .RuleFor(x => x.Weight, f => f.Lorem.Sentence())
                            .RuleFor(x => x.Height, f => f.Lorem.Sentence())
                            .RuleFor(x => x.SkinColor, f => f.Commerce.Color())
                            .RuleFor(x => x.Race, f => f.PickRandom(race))
                            .RuleFor(x => x.Faction, f => f.PickRandom(faction))
                            .RuleFor(x => x.Background, f => f.Lorem.Paragraphs(7))
                            .RuleFor(x => x.Residence, f => f.Lorem.Word())
                            .RuleFor(x => x.Occupation, f => f.Lorem.Sentence())
                            .RuleFor(x => x.PhysicalAppearance, f => f.Lorem.Paragraphs(2))
                            .RuleFor(x => x.Friends, f => f.Lorem.Words().ToList())
                            .RuleFor(x => x.Stories, f => story.Generate(random.Number(1, 10)).ToList())
                            .RuleFor(x => x.Pictures, f => picture.Generate(random.Number(1, 10)).ToList())
                            .RuleFor(x => x.Guild, f => guild.Generate())
                            .RuleFor(x => x.DateInfo, f => dateInfo.Generate());



            var user = new Faker <User>()
                       .StrictMode(true)
                       .RuleFor(x => x.UserName, f => f.Internet.UserName())
                       .RuleFor(x => x.DateInfo, dateInfo.Generate())
                       .RuleFor(x => x.Email, f => f.Internet.Email())
                       .RuleFor(x => x.Image, f => f.Internet.Url())
                       .RuleFor(x => x.IsActive, f => f.PickRandom(isActive))
                       .RuleFor(x => x.Characters, f => character.Generate(random.Number(1, 10)).ToList());


            var users = user.Generate(1000);
            //string charsJson = JsonConvert.SerializeObject(users);
            ElasticClient client = ElasticClientFactory.GetClient();
            //File.WriteAllText(@"c:\dump\users.txt", charsJson);

            var result = client.Bulk(b => b.IndexMany(users));

            if (!result.IsValid)
            {
                foreach (var item in result.ItemsWithErrors)
                {
                    Console.WriteLine("Failed to index document {0}: {1}", item.Id, item.Error);
                }

                Console.WriteLine(result.DebugInformation);
                Console.Read();
                Environment.Exit(1);
            }

            Console.WriteLine("Done!");
            Console.ReadLine();
        }
        protected override void Seed(MyContext context)
        {
            AppUser admin = new AppUser();

            admin.UserName = "******";
            admin.Password = "******";
            admin.Email    = "*****@*****.**";
            context.AppUsers.Add(admin);
            context.SaveChanges();

            AppUserDetail admind = new AppUserDetail();

            admind.ID        = admin.ID;
            admind.FirstName = "Berke";
            admind.LastName  = "Güzel";
            admind.Address   = "Maltepe";
            context.AppUserDetails.Add(admind);
            context.SaveChanges();

            AppUser member = new AppUser();

            member.UserName = "******";
            member.Password = "******";
            member.Email    = "*****@*****.**";
            context.AppUsers.Add(member);
            context.SaveChanges();

            AppUserDetail memberd = new AppUserDetail();

            memberd.ID        = member.ID;
            memberd.FirstName = "Berke";
            memberd.LastName  = "Güzel";
            memberd.Address   = "Maltepe";
            context.AppUserDetails.Add(memberd);
            context.SaveChanges();

            for (int i = 0; i < 10; i++)
            {
                AppUser ap = new AppUser();
                ap.UserName = new Internet("tr").UserName();
                ap.Password = new Internet("tr").Password();
                ap.Email    = new Internet("tr").Email();
                context.AppUsers.Add(ap);
                context.SaveChanges();

                AppUserDetail apd = new AppUserDetail();
                apd.ID        = ap.ID;
                apd.FirstName = new Name("tr").FirstName();
                apd.LastName  = new Name("tr").LastName();
                apd.Address   = new Address("tr").Locale;
                context.AppUserDetails.Add(apd);
                context.SaveChanges();
            }


            //for (int i = 0; i < 11; i++)
            //{
            //    AppUserDetail apd = new AppUserDetail();
            //    apd.ID = i;
            //    apd.FirstName = new Name("tr").FirstName();
            //    apd.LastName = new Name("tr").LastName();
            //    apd.Address = new Address("tr").Locale;
            //    context.AppUserDetails.Add(apd);
            //}
            //context.SaveChanges();

            for (int i = 0; i < 10; i++)
            {
                Category c = new Category();
                c.CategoryName = new Commerce("tr").Categories(1)[0];
                c.Description  = new Lorem("tr").Sentence(100);

                for (int x = 0; x < 50; x++)
                {
                    Randomizer random = new Bogus.Randomizer();
                    Product    p      = new Product();
                    p.ProductName  = new Commerce("tr").ProductName();
                    p.UnitPrice    = Convert.ToDecimal(new Commerce("tr").Price());
                    p.ImagePath    = new Images("en").Nightlife();
                    p.UnitsInStock = Convert.ToInt16(random.Number(1, 500));
                    p.Description  = new Lorem("tr").Sentence(5);
                    c.Products.Add(p);
                }
                context.Categories.Add(c);
                context.SaveChanges();
            }
        }
Exemple #16
0
 internal Person(Randomizer randomizer, string locale = "en")
 {
     this.GetDataSources(locale);
     this.Random = randomizer;
     this.Populate();
 }
Exemple #17
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            // Freeze Seed in order to make debugging easier (keeping the same user Id's
            Randomizer.Seed = new Random(8675309);

            var roomNumbers = new[] { "1A", "2A", "3A", "4A", "5A", "6A", "1B", "2B", "3B", "4B", "5B", "6B", "1.004785", "N100.45", "545", "0.0454a", "Apl", "F-54689", "F54689" };

            #region Location

            var maxLocation   = 3;
            var locationFaker = new Faker <Location>()
                                .StrictMode(false)
                                .Rules((f, l) =>
            {
                var address = f.Address;
                l.Id        = f.IndexVariable++ + 1;
                l.Country   = address.CountryCode();
                l.ShortName = new Bogus.Randomizer().Replace("??");
                l.Name      = address.City();
            });
            var locationList = Enumerable.Range(1, maxLocation)
                               .Select(_ => locationFaker.Generate());
            foreach (var location in locationList)
            {
                modelBuilder.Entity <Location>().HasData(location);
            }

            #endregion Location

            #region Building

            var maxBuildings  = 10;
            var buildingFaker = new Faker <Building>()
                                .StrictMode(false)
                                .Rules((f, b) =>
            {
                var address  = f.Address;
                b.Id         = f.IndexVariable++ + 1;
                b.Name       = address.StreetName();
                b.Number     = address.BuildingNumber();
                b.Address    = address.FullAddress();
                b.ShortName  = new Bogus.Randomizer().Replace("???");
                b.LocationId = f.Random.Number(1, maxLocation);
            });
            var buildingList = Enumerable.Range(1, maxBuildings)
                               .Select(_ => buildingFaker.Generate())
                               .ToList();
            foreach (var building in buildingList)
            {
                modelBuilder.Entity <Building>().HasData(building);
            }

            #endregion Building

            #region Floor
            var maxFloors  = 100;
            var floorFaker = new Faker <Floor>()
                             .StrictMode(false)
                             .Rules((f, b) =>
            {
                b.Id          = f.IndexVariable++ + 1;
                b.Number      = new Bogus.Randomizer().Number(-5, 20);
                b.Description = new Bogus.Randomizer().Replace($"??/?#/{b.Number}. Etage");
                b.BuildingId  = f.PickRandom(buildingList).Id;
            });
            var floorList = Enumerable.Range(1, maxFloors)
                            .Select(_ => floorFaker.Generate())
                            .ToList();
            foreach (var floor in floorList)
            {
                modelBuilder.Entity <Floor>().HasData(floor);
            }
            #endregion Floor

            #region BuildingPart

            var maxBuildingParts  = 40;
            var BuildingPartFaker = new Faker <BuildingPart>()
                                    .StrictMode(false)
                                    .Rules((f, b) =>
            {
                b.Id          = f.IndexVariable++ + 1;
                b.Description = new Bogus.Randomizer().Replace($"Part ?");
                b.BuildingId  = f.PickRandom(buildingList).Id;
            });
            var BuildingPartList = Enumerable.Range(1, maxBuildingParts)
                                   .Select(_ => BuildingPartFaker.Generate())
                                   .ToList();
            foreach (var BuildingPart in BuildingPartList)
            {
                modelBuilder.Entity <BuildingPart>().HasData(BuildingPart);
            }
            #endregion BuildingPart

            #region Room

            var maxRooms  = 1000;
            var RoomFaker = new Faker <Room>()
                            .StrictMode(false)
                            .Rules((f, b) =>
            {
                b.Id             = f.IndexVariable++ + 1;
                b.Number         = f.PickRandom(roomNumbers);
                b.Map            = f.PickRandom(new[] { "sample_static", "sample_highlight" });
                b.BuildingPartId = f.PickRandom(BuildingPartList).Id;
                b.FloorId        = f.PickRandom(floorList).Id;
            });
            var RoomList = Enumerable.Range(1, maxRooms)
                           .Select(_ => RoomFaker.Generate())
                           .ToList();
            foreach (var Room in RoomList)
            {
                modelBuilder.Entity <Room>().HasData(Room);
            }
            #endregion Room

            #region OrgUnit
            var maxOrgUnits  = 500;
            var OrgUnitFaker = new Faker <OrgUnit>()
                               .StrictMode(false)
                               .Rules((f, b) =>
            {
                b.Id         = f.IndexVariable++ + 1;
                b.Name       = f.Commerce.Department();
                b.ShortName  = new Bogus.Randomizer().Replace("**");
                b.ParentId   = null;
                b.CostCenter = new Bogus.Randomizer().Replace("####");
            });
            var OrgUnitList = Enumerable.Range(1, maxOrgUnits)
                              .Select(_ => OrgUnitFaker.Generate())
                              .ToList();

            var boolRandomizer = new Bogus.Randomizer();
            var randomPicker   = new Faker();
            foreach (var OrgUnit in OrgUnitList)
            {
                if (boolRandomizer.Bool())
                {
                    var maybeParent = randomPicker.PickRandom(OrgUnitList);
                    while (
                        maybeParent.Id == OrgUnit.Id ||
                        maybeParent.ParentId == OrgUnit.Id)
                    {
                        maybeParent = randomPicker.PickRandom(OrgUnitList);
                    }

                    OrgUnit.ParentId = maybeParent.ParentId;
                }
                modelBuilder.Entity <OrgUnit>().HasData(OrgUnit);
            }
            #endregion OrgUnit

            #region Status
            modelBuilder.Entity <Status>().HasData(new Status {
                Id = Status1Id, Name = "head of", Code = "Ho"
            });
            modelBuilder.Entity <Status>().HasData(new Status {
                Id = Status2Id, Name = "internal employee", Code = "IE"
            });
            modelBuilder.Entity <Status>().HasData(new Status {
                Id = Status3Id, Name = "external employee", Code = "EX"
            });
            modelBuilder.Entity <Status>().HasData(new Status {
                Id = Status4Id, Name = "student employee", Code = "SE"
            });
            #endregion Status

            #region Funktion
            modelBuilder.Entity <Function>().HasData(new Function {
                Id = Function1Id, Code = "SO", Label = "software engineer"
            });
            modelBuilder.Entity <Function>().HasData(new Function {
                Id = Function2Id, Code = "SY", Label = "system engineer"
            });
            modelBuilder.Entity <Function>().HasData(new Function {
                Id = Function3Id, Code = "HO", Label = "head of"
            });
            modelBuilder.Entity <Function>().HasData(new Function {
                Id = Function4Id, Code = string.Empty, Label = string.Empty
            });
            #endregion Funktion

            #region Person

            var maxPersons  = 1500;
            var PersonFaker = new Faker <Person>()
                              .StrictMode(false)
                              .Rules((f, b) =>
            {
                b.Id         = f.IndexVariable++ + 1;
                b.ShortName  = f.Random.Replace("####");
                b.EMail      = f.Person.Email;
                b.FAX        = f.Phone.PhoneNumber();
                b.FirstName  = f.Name.FirstName();
                b.LastName   = f.Name.LastName();
                b.MobilPhone = f.Phone.PhoneNumber();
                b.Phone      = f.Phone.PhoneNumber();
                b.Title      = f.PickRandom(new[] { "Dr.", string.Empty, string.Empty, "Prof." });
                b.StatusId   = f.Random.Number(1, 4);
                b.FunctionId = f.Random.Number(1, 4);
                b.OrgUnitId  = f.PickRandom(OrgUnitList).Id;
                b.RoomId     = f.PickRandom(RoomList).Id;
            });
            var PersonList = Enumerable.Range(1, maxPersons)
                             .Select(_ => PersonFaker.Generate())
                             .ToList();
            foreach (var Person in PersonList)
            {
                if (boolRandomizer.Bool())
                {
                    var orgUnit = new Faker().PickRandom(OrgUnitList);
                    if (orgUnit.Id != Person.OrgUnitId)
                    {
                        orgUnit.HeadOfOrgUnitId = Person.Id;
                    }
                }
                modelBuilder.Entity <Person>().HasData(Person);
            }

            #endregion Person

            #region OrgUnitToFunktion

            var faker = new Faker();
            foreach (var person in PersonList)
            {
                modelBuilder.Entity <OrgUnitToFunction>().HasData(
                    new OrgUnitToFunction {
                    FunctionId = faker.Random.Number(1, 4),
                    OrgUnitId  = faker.PickRandom(OrgUnitList).Id,
                    PersonId   = person.Id,
                    RoleName   = faker.Random.Replace("###").ToUpper()
                });
            }
            #endregion OrgUnitToFunktion
        }
Exemple #18
0
    public void UpdatePhone(RaycastHit2D hit)
    {
        var c = hit.collider;
        var x = c.transform.parent.gameObject.name;

        switch (x)
        {
        case ("Alarm"):
            if (AlarmC <= money)
            {
                buy.Play();
                hasAlarm     = true;
                money       -= AlarmC;
                GameData.ase = true;
                Destroy(AlarmGO);
            }
            break;

        case ("ExerciseBike"):
            if (money >= BikeC)
            {
                buy.Play();
                hasBike      = true;
                money       -= BikeC;
                GameData.bse = true;
                Destroy(BikeGO);
            }
            break;

        case ("Fridge"):
            if (money >= fCost[F])
            {
                buy.Play();

                GameData.fse        = true;
                FridgeSprite.sprite = fridge[F];
                money -= fCost[F];

                maxFood += Fbonus[F];
                F       += 1;
            }
            if (F == 3)
            {
                Destroy(FridgeGO);
                F = 2;
            }
            break;

        case ("Bed"):
            if (money >= bCost[B])
            {
                buy.Play();
                GameData.bese    = true;
                BedSprite.sprite = bed[B];
                money           -= bCost[B];
                B += 1;
            }
            if (B == 3)
            {
                Destroy(BedGO);
                B = 2;
            }
            break;

        case ("Coffee"):
            if (money >= cCost[C])
            {
                buy.Play();
                GameData.cse        = true;
                CoffeeSprite.sprite = coffee[C];
                money -= cCost[C];
                C     += 1;
            }
            if (C == 3)
            {
                Destroy(CoffeeGO);
                C = 2;
            }
            break;

        case ("Mask"):
            if (money >= mCost[M])
            {
                buy.Play();
                money           -= mCost[M];
                M               += 1;
                GameData.hasmask = true;
            }
            if (M == 4)
            {
                Destroy(MaskGO);
                M = 3;
            }
            break;

        case ("Food"):
            if (FoodC <= money && (GameData.food + 40) < GameData.maxfood)
            {
                buy.Play();
                money -= FoodC;
                food  += 40;
            }
            break;
        }



        if (hit.collider.gameObject.name == "Door")
        {
            if (GameData.food > 0)
            {
                GameData.dayswofood = 0;
            }
            if (GameData.day >= 3)
            {
                var random = new Bogus.Randomizer();
                int num    = random.Number(1, 4);
                if (num == 1)
                {
                    GameData.isill = true;
                }
            }
            else
            {
                GameData.isill = false;
            }
            door.Play();
            CalculateEnergy();
            if (!hasAlarm)
            {
                var random = new Bogus.Randomizer();
                int num    = random.Number(1, 4 - GameData.m);
                if (num == 1)
                {
                    GameData.hour   = 12;
                    GameData.energy = GameData.Maxenergy;
                    GameData.late   = true;
                }
                else
                {
                    GameData.hour   = 9;
                    GameData.energy = GameData.Maxenergy * 0.8f;
                    GameData.late   = false;
                }
            }
            else
            {
                GameData.hour   = 9;
                GameData.energy = GameData.Maxenergy * 0.8f;
                GameData.late   = false;
            }
            GameData.day = GameData.day + 1;
            GameData.b   = B;
            GameData.f   = F;
            GameData.c   = C;
            GameData.m   = M;
            StartCoroutine(LoadScene());
        }
    }
Exemple #19
0
 public static IPeerIdentification PeerIdentification(this Bogus.Randomizer randomizer)
 {
     return(StringPeerIdentification.Generate());
 }