public void AddReviewShouldAddReview(int rating, int expected) { var options = new DbContextOptionsBuilder <XeonDbContext>() .UseInMemoryDatabase(databaseName: $"AddReviews_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 product = new Product { Name = "USB ", ChildCategory = childCategory }; dbContext.Products.Add(product); dbContext.SaveChanges(); productService.AddReview(rating, product.Id); Assert.Equal(expected, product.Reviews.Count()); }