public void Create_WhenManufactuerWithTwoProducts_AddsEntriesToDb() { var manufacturer = new Manufacturer { Country = "Lithuania", Name = "Toy Lasers", Products = new List <Product> { new() { Name = "Laser S", Price = 4.01m }, new() { Name = "Laser M", Price = 7.99m } } }; _manufacturersRepository.Create(manufacturer); var toyLasersManufacturer = _db.Manufacturers .Include(m => m.Products) .Where(m => m.Name == "Toy Lasers"); Assert.AreEqual(2, toyLasersManufacturer.First().Products.Count); _db.Manufacturers.RemoveRange(toyLasersManufacturer); _db.SaveChanges(); }
internal Manufacturer Create(Manufacturer newManufacturer) { Manufacturer created = _repo.Create(newManufacturer); if (created == null) { throw new Exception("Create Request Failed"); } return(created); }
internal object Create(Manufacturer newManufacturer) { return(_repo.Create(newManufacturer)); }