private void Seed() { using (var context = new ShopsContext(ContextOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var shop = new Shop() { Id = Guid.NewGuid(), Name = "Aldi", Products = new List <Product>() { new Product() { Name = "pomme", Price = 5 } } }; context.AddRange(shop); context.SaveChanges(); } }
public void When_Get_Shops_Then_Shops_Are_Retrived() { using (var context = new ShopsContext(ContextOptions)) { //Arrange var repository = new Repository.Repository(_mapper, context); //Act var items = repository.GetShops(); //Assert Assert.IsNotEmpty(items); } }
public void When_Create_Shop_Then_Shop_Are_Created() { using (var context = new ShopsContext(ContextOptions)) { //Arrange var repository = new Repository.Repository(_mapper, context); var shopRequest = new ShopRequest() { Name = "Colruyt" }; //Act var item = repository.Insert(shopRequest); //Assert Assert.IsNotNull(item); Assert.AreEqual("Colruyt", item.Name); } }
public void When_Get_Shop_By_Id_Then_Shop_Are_Retrived() { using (var context = new ShopsContext(ContextOptions)) { //Arrange var repository = new Repository.Repository(_mapper, context); var shopRequest = new ShopRequest() { Name = "C&A" }; var item = repository.Insert(shopRequest); //Act item = repository.GetShop(item.Id); //Assert Assert.IsNotNull(item); Assert.AreEqual("C&A", item.Name); } }
public void When_Delete_Shop_Then_Shop_Are_Removed() { using (var context = new ShopsContext(ContextOptions)) { //Arrange var repository = new Repository.Repository(_mapper, context); var shopRequest = new ShopRequest() { Name = "Carrefour" }; var item = repository.Insert(shopRequest); //Act repository.Delete(item.Id); item = repository.GetShop(item.Id); //Assert Assert.IsNull(item); } }
public ShopsController() { db = new ShopsContext(); }
public ShopRepository(ShopsContext context) { db = context; }
public ProductsController() { db = new ShopsContext(); }
public ShopRepository(ShopsContext context) { _database = context; }
public ShopsRepository(ShopsContext shopsContext) { _shopsContext = shopsContext; }
public Repository(IMapper mapper, ShopsContext dbcontext) { _mapper = mapper; _dbcontext = dbcontext; }
public ProductRepository(ShopsContext context) { _database = context; }
public ProductRepository(ShopsContext context) { db = context; }
public Provider() { db = new ShopsContext(); }
public EFUnitOfWork(string connectionString) { db = new ShopsContext(connectionString); }