public static void EnsureTestdataSeeding(this MainDbContext context)
        {
            EnsureDataSeeded(context);


            if (!context.Users.Any())
            {
                context.Users.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <ApplicationUser>());
                context.SaveChanges();
            }

            if (!context.Roles.Any())
            {
                context.Roles.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <ApplicationRole>());
                context.SaveChanges();
            }

            if (!context.RoleClaims.Any())
            {
                context.RoleClaims.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <ApplicationRoleClaim>());
                context.SaveChanges();
            }

            if (!context.UserClaims.Any())
            {
                context.UserClaims.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <ApplicationUserClaim>());
                context.SaveChanges();
            }

            if (!context.UserRoles.Any())
            {
                context.UserRoles.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <ApplicationUserRole>());
                context.SaveChanges();
            }
        }
        public static void EnsureTestdataSeeding(this SalesDbContext context)
        {
            EnsureDataSeeded(context);

            if (!context.Customer.Any())
            {
                context.Customer.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <Customer>());
                context.SaveChanges();
            }
        }
        public async Task Should_get_user_by_given_id_status_code_ok()
        {
            var requestedUserId = SeedDataBuilder.BuildTypeCollectionFromFile <ApplicationUser>().First();

            HttpResponseMessage response;
            var server = CreateServer(directory);
            {
                response = await server.CreateAuthenticatedClient()
                           .GetAsync(Get.UserBy(requestedUserId.Id));

                response.EnsureSuccessStatusCode();
            }
            var userResult = await DeserializeContentStringAsync <JObject>(response);

            Assert.IsNotNull(userResult);
        }
Exemplo n.º 4
0
        public static void EnsureTestdataSeeding(this MainDbContext context)
        {
            EnsureDataSeeded(context);

            if (!context.Currency.Any())
            {
                context.Currency.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <Currency>());
                context.SaveChanges();
            }

            if (!context.Person.Any())
            {
                context.Person.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <Person>());
                context.SaveChanges();
            }

            if (!context.EmailAddress.Any())
            {
                context.EmailAddress.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <EmailAddress>());
                context.SaveChanges();
            }

            if (!context.CreditCard.Any())
            {
                context.CreditCard.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <CreditCard>());
                context.SaveChanges();
            }

            if (!context.CurrencyRate.Any())
            {
                context.CurrencyRate.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <CurrencyRate>());
                context.SaveChanges();
            }

            if (!context.Country.Any())
            {
                context.Country.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <Country>());
                context.SaveChanges();
            }

            if (!context.Province.Any())
            {
                context.Province.AddRange(SeedDataBuilder.BuildTypeCollectionFromFile <Province>());
                context.SaveChanges();
            }
        }