コード例 #1
0
        protected override void Seed(ToDoDotNet.Data.ToDoDbContext context)
        {
            var lorem = new Bogus.DataSets.Lorem();
            var dates = new Bogus.DataSets.Date();

            context.ToDos.AddOrUpdate(x => x.Id,
                                      new ToDo()
            {
                Title = lorem.Word(), Body = lorem.Sentences(), CreationDate = dates.Soon()
            },
                                      new ToDo()
            {
                Title = lorem.Word(), Body = lorem.Sentences(), CreationDate = dates.Soon()
            },
                                      new ToDo()
            {
                Title = lorem.Word(), Body = lorem.Sentences(), CreationDate = dates.Soon()
            },
                                      new ToDo()
            {
                Title = lorem.Word(), Body = lorem.Sentences(), CreationDate = dates.Soon()
            },
                                      new ToDo()
            {
                Title = lorem.Word(), Body = lorem.Sentences(), CreationDate = dates.Soon()
            }
                                      );
        }
コード例 #2
0
        public CustomerFaker()
        {
            var lorem = new Bogus.DataSets.Lorem(locale: "pl");

            UseSeed(1);
            RuleFor(p => p.Id, f => f.IndexFaker);
            RuleFor(p => p.FirstName, f => f.Person.FirstName);
            RuleFor(p => p.LastName, f => f.Person.LastName);
            RuleFor(p => p.Gender, f => (Gender)f.Person.Gender);
            RuleFor(p => p.Email, (f, customer) => $"{customer.FirstName}.{customer.LastName}@domain.com"); // [email protected]
            RuleFor(p => p.Description, f => lorem.Sentences(3));
            RuleFor(p => p.Birthday, f => f.Person.DateOfBirth);
            RuleFor(p => p.Type, f => f.PickRandom <CustomerType>());
            RuleFor(p => p.CreditAmount, f => f.Random.Decimal(1m, 1000m).OrNull(f, 0.3f));
            RuleFor(p => p.IsRemoved, f => f.Random.Bool(0.2f));
            RuleFor(p => p.Pesel, f => f.Person.Pesel());

            RuleFor(p => p.Username, f => f.Person.UserName);
            RuleFor(p => p.HashedPassword, f => "12345");
        }