public void CleanData() { using (var context = new TechnicalTestDbContext()) { var repository = new CompaniesRepository(context); var allItems = repository.Get().ToList(); allItems.ForEach(repository.Delete); context.SaveChanges(); } }
public void GivenIHaveTheFollowingCompaniesWithDefaultInformation(Table table) { var items = table.CreateSet <CompanyDetailsSpecflowItem>(); using (var context = new TechnicalTestDbContext()) { var repository = new CompaniesRepository(context); var allItems = repository.Get().ToList(); allItems.ForEach(repository.Delete); items.ForEach(x => { repository.Insert(new Company { Name = x.CompanyName }); }); context.SaveChanges(); } }
protected async Task SeedMockDataAsync(TechnicalTestDbContext context) { context.Database.EnsureCreated(); await context.Categories.AddRangeAsync( new Categories { CategoryId = 1, Name = "Category1", Deleted = false }, new Categories { CategoryId = 2, Name = "Category2", Deleted = false } ); await context.Products.AddRangeAsync( new Products { ProductId = 1, Name = "Product1", CategoryId = 1 }, new Products { ProductId = 2, Name = "Product2", CategoryId = 2 }, new Products { ProductId = 3, Name = "Product3", CategoryId = 1 } ); context.SaveChanges(); }