public void AddImageUrlsShouldAddImageUrls() { var options = new DbContextOptionsBuilder <XeonDbContext>() .UseInMemoryDatabase(databaseName: "AddImageUrls_Product_Database") .Options; var dbContext = new XeonDbContext(options); var productService = new ProductsService(dbContext); var parentCategory = new ParentCategory { Name = "Computers" }; var childCategory = new ChildCategory { Name = "Cables", ParentCategory = parentCategory }; dbContext.ChildCategories.Add(childCategory); dbContext.SaveChanges(); var productName = "USB"; dbContext.Products.AddRange(new List <Product> { new Product { Name = productName, ChildCategory = childCategory }, new Product { Name = "Cable", ChildCategory = childCategory }, new Product { Name = "Keyboard", ChildCategory = childCategory }, new Product { Name = "Computer", ChildCategory = childCategory }, }); dbContext.SaveChanges(); var productId = dbContext.Products.FirstOrDefault(x => x.Name == productName).Id; var imageUrls = new List <string> { "wwwroot/image1", "wwwroot/image2", "wwwroot/image3" }; productService.AddImageUrls(productId, imageUrls); var product = dbContext.Products.FirstOrDefault(x => x.Id == productId); Assert.Equal(3, product.Images.Count); }