public void NextCarShouldGenerateRandomCars()
        {
            var uniqueCars = new HashSet <Car>();
            int count      = 1000;

            for (int i = 0; i < count; i++)
            {
                var car = CarSeeder.NextCar();
                //Debug.WriteLine(car.Manufacturer);
                //Debug.WriteLine(car.Model);
                //Debug.WriteLine(car.VIN);
                //Debug.WriteLine(car.Year);
                //Debug.WriteLine(car.PlateCode);
                //Debug.WriteLine(car.EngineCode);
                uniqueCars.Add(car);
            }

            Assert.AreEqual(count, uniqueCars.Count);
        }
        protected override void Seed(MyDbContext context)
        {
            //  This method will be called after migrating to the latest version.
            //ClearDatabase<MyDbContext>();
            context = new MyDbContext();

            #region Seeding ApplicationUsers
            bool exists = context.Users
                          .Any(u => u.UserName == "*****@*****.**");

            if (!exists)
            {
                var store   = new UserStore <ApplicationUser>(context);
                var manager = new UserManager <ApplicationUser>(store);
                var user    = new ApplicationUser
                {
                    UserName    = "******",
                    Email       = "*****@*****.**",
                    PhoneNumber = "088888888",
                    UserDetails = new UserDetails
                    {
                        FirstName   = "Ivan",
                        LastName    = "Petrov",
                        CompanyName = "Auto Repair",
                        City        = "Ruse"
                    }
                };

                manager.Create(user, "password");
                #endregion

                #region Seeding customers and their cars
                var currentUser   = manager.FindByEmail("*****@*****.**");
                var customersList = new List <Customer>();
                var cars          = new List <Car>();

                for (int i = 0; i < 40; i++)
                {
                    var customer = CustomerSeeder.NextCustomer(currentUser);
                    for (int j = 0; j < 3; j++)
                    {
                        var car = CarSeeder.NextCar(currentUser, customer);
                        cars.Add(car);
                        customer.Cars.Add(car);
                    }
                    customersList.Add(customer);
                }

                customersList.ForEach(c => context.Customers.Add(c));
                context.SaveChanges();
                #endregion

                #region Suppliers seeding
                var suppliersToAdd = new List <Supplier>
                {
                    new Supplier
                    {
                        Name = "No supplier",
                        DiscountPercentage = 0.0m,
                        User      = currentUser,
                        IsDeleted = true,
                        IsDefault = true
                    },
                    new Supplier
                    {
                        Name = "Euro 07",
                        DiscountPercentage = 45.0m,
                        City         = "Rousse",
                        WebsiteUrl   = "http://euro07.bg",
                        EmailAddress = "*****@*****.**",
                        SkypeName    = "euro07.ruse",
                        User         = currentUser
                    },
                    new Supplier
                    {
                        Name = "Auto Plus",
                        DiscountPercentage = 33.0m,
                        City         = "Rousse",
                        WebsiteUrl   = "http://autoplus.bg",
                        EmailAddress = "*****@*****.**",
                        SkypeName    = "autoplus",
                        User         = currentUser
                    },
                    new Supplier
                    {
                        Name = "Auto Commerce",
                        DiscountPercentage = 25.0m,
                        City       = "Rousse",
                        WebsiteUrl = "http://acommers.bg",
                        User       = currentUser
                    },
                    new Supplier
                    {
                        Name = "Mega Parts",
                        DiscountPercentage = 10.0m,
                        City         = "Sofia",
                        WebsiteUrl   = "http://megaparts.bg",
                        EmailAddress = "*****@*****.**",
                        User         = currentUser
                    },
                    new Supplier
                    {
                        Name = "Inter Cars",
                        DiscountPercentage = 40.0m,
                        City       = "Rousse",
                        WebsiteUrl = "http://intercars.bg",
                        SkypeName  = "intercars-bg",
                        User       = currentUser
                    },
                    new Supplier
                    {
                        Name = "Auto Morgue",
                        DiscountPercentage = 0.0m,
                        City       = "Rousse",
                        WebsiteUrl = "",
                        User       = currentUser
                    }
                };
                suppliersToAdd.ForEach(s => context.Suppliers.Add(s));
                context.SaveChanges();
                #endregion

                #region Jobs seeding
                foreach (var car in cars)
                {
                    var jobs = new List <Job>();
                    for (int i = 0; i < 3; i++)
                    {
                        jobs.Add(JobSeeder.NextJob(user, car, car.Customer));
                    }
                    jobs.ForEach(j => context.Jobs.Add(j));
                    jobs.ForEach(j => j.SpareParts.ForEach(
                                     sp => context.SpareParts.Add(sp)));
                }
                SaveChanges(context);
                #endregion
            }
            ;
        }