public void GetAllReviewsShould_ReturnAllReviewsFromCustomers() { var options = new DbContextOptionsBuilder <CarRentalDbContext>() .UseInMemoryDatabase(databaseName: "CarRental_Database_AllReviews") .Options; var dbContext = new CarRentalDbContext(options); var user = new ApplicationUser() { Id = Guid.NewGuid().ToString(), Email = "*****@*****.**", FirstName = "Admin", LastName = "LastAdmin" }; var vouchersServiceMock = new Mock <IVouchersService>(); vouchersServiceMock.Setup(x => x.CreateForUser(user.Email)). ReturnsAsync(true); var ordersServiceMock = new Mock <IOrdersService>(); ordersServiceMock.Setup(x => x.DeleteReviewFromOrder(It.IsAny <int>())). ReturnsAsync(true); var random = new Random(); var reviewsService = new ReviewsService(dbContext, vouchersServiceMock.Object, this.mapper, ordersServiceMock.Object); var ordersToInsert = 10; for (int i = 1; i <= ordersToInsert; i++) { var order = new Order { Id = Guid.NewGuid().ToString(), ApplicationUserId = user.Id, CarId = 1, PickUpLocationId = 1, ReturnLocationId = 1, Price = 1, }; var reviewRating = random.Next(1, 5); var reviewComment = Guid.NewGuid().ToString(); order.Review = new Review { Comment = reviewComment, Rating = reviewRating, Id = i, CarId = 1 }; dbContext.Orders.Add(order); dbContext.SaveChanges(); } var expected = ordersToInsert; var result = reviewsService.GetAllReviews().Count(); Assert.Equal(expected, result); }