public void TestAddingAndRemovingProduct() { IProductCategoryRepository productCategoryRepository = new EFProductCategoryRepository(context); var pizzaCategory = productCategoryRepository.ProductCategoryRepository.First(pc => pc.Name == "Pizza"); IProductRepository productRepository = new EFProductRepository(context); var product = new Product { Allergens = new List <Allergen> { new Allergen { Description = "Opis alergenu", Title = "JakisAlergen" } }, Description = "OpisOpisOpisOpis", BasePrice = 29.99m, PrepareTime = TimeSpan.FromMinutes(30), ProductCategory = pizzaCategory, Title = "Wiejska" }; productRepository.AddNewProduct(product); Assert.IsTrue(productRepository.ProductRepository.Any(p => p.Title == "Wiejska"), "Added product not in the database"); Assert.IsTrue(context.Allergens.Any(al => al.Title == "JakisAlergen"), "Added allergen not in the database"); productRepository.RemoveProduct(product); Assert.IsFalse(productRepository.ProductRepository.Any(p => p.Title == "Wiejska"), "Removed product still in the database"); Assert.IsTrue(context.Allergens.Any(al => al.Title == "JakisAlergen"), "Allergen not in database"); }
public RepositoriesTest() { _productRepository = new EFProductRepository( _context ); _productCategoryRepository = new EFProductCategoryRepository( _context ); _productUserRepository = new EFProductUserRepository( _context ); _userRepository = new EFUserRepository( _context ); }