Esempio n. 1
0
        public static void Configure(DbFactory factory)
        {
            factory.Define <User>(u =>
            {
                u.Email     = MockString.GetEmail();
                u.FirstName = MockString.GetName();
                u.LastName  = MockString.GetName();
                u.Id        = Guid.NewGuid();
                u.LastLogin = new DateTime();
            });

            factory.Define <Data.Task>(d =>
            {
                d.Id       = Guid.NewGuid();
                d.Priority = Data.Priority.High;
                d.State    = Data.State.InProgress;
                d.Title    = "title";
                d.Type     = Data.Type.UserStory;
            });

            factory.Define <TaskComment>(dm =>
            {
                var user       = factory.Create <User>();
                var d          = factory.Create <Data.Task>();
                dm.DateCreated = DateTime.Now;
                dm.TaskId      = d.Id;
                dm.Id          = Guid.NewGuid();
                dm.UserId      = user.Id;
            });
        }
        protected override void Seed(GoodsStoreContext context)
        {
            base.Seed(context);

            for (int i = 0; i < 3; i++)
            {
                context.Users.Add(new User
                {
                    Id           = Guid.NewGuid(),
                    Email        = MockString.GetEmail(),
                    FirstName    = MockString.GetFirstName(),
                    LastName     = MockString.GetLastName(),
                    HashPassword = Crypto.HashPassword(MockString.GetPassword()),
                });

                context.SaveChanges();
            }

            for (int i = 0; i < 7; i++)
            {
                context.Products.Add(new Product
                {
                    Id          = Guid.NewGuid(),
                    Description = MockString.GetDescription(),
                    Title       = MockString.GetTitle(),
                    Price       = MockNumber.GetNumber()
                });

                context.SaveChanges();
            }

            for (int i = 0; i < 15; i++)
            {
                var order = new Order
                {
                    Anotation = MockString.GetNotation()
                };

                order.Products.Add(context.Products.ToList()[MockNumber.GetNumber(0, context.Products.ToList().Count)]);
                order.Users.Add(context.Users.ToList()[MockNumber.GetNumber(0, context.Users.ToList().Count)]);

                context.Orders.Add(order);
            }
        }