public async Task AddProductImageShouldAddNewImage() { var options = new DbContextOptionsBuilder <WHMSDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; using var context = new WHMSDbContext(options); var product = new Product { ProductName = "Test Product", ShortDescription = "Test Product", }; context.Products.Add(product); await context.SaveChangesAsync(); var mockInventoryService = new Mock <IInventoryService>(); var service = new ProductsService(context, mockInventoryService.Object); var image = new ImageViewModel { ProductId = product.Id, Url = "https://c8.alamy.com/comp/D8RWP0/url-of-web-browser-D8RWP0.jpg" }; await service.AddProductImageAsync(image); Assert.True(context.Images.Count() == 1); }