public void GetAllMoviesFromUserCartShouldReturnDictionaryOfMoviesAndInts() { DbContextOptions <UltimateMoviesDbContext> options = new DbContextOptionsBuilder <UltimateMoviesDbContext>() .UseInMemoryDatabase(databaseName: "Carts_GetAllMoviesFromUserCart_Database") .Options; UltimateMoviesDbContext db = new UltimateMoviesDbContext(options); ICartsService cartsService = new CartsService(db); db.Users.Add(new UMUser { UserName = "******" }); db.SaveChanges(); db.Movies.Add(new Movie { Name = "Test Movie" }); db.Movies.Add(new Movie { Name = "Test Movie 2" }); db.Movies.Add(new Movie { Name = "Test Movie 3" }); db.SaveChanges(); db.CartMovies.Add(new CartMovie { UserId = db.Users.Last().Id, MovieId = db.Movies.ToList()[0].Id, Quantity = 1 }); db.CartMovies.Add(new CartMovie { UserId = db.Users.Last().Id, MovieId = db.Movies.ToList()[1].Id, Quantity = 1 }); db.CartMovies.Add(new CartMovie { UserId = db.Users.Last().Id, MovieId = db.Movies.ToList()[2].Id, Quantity = 1 }); db.SaveChanges(); Dictionary <Movie, int> movies = cartsService.GetAllMoviesFromUserCart("Test"); int moviesCount = movies.Count(); Assert.Equal(3, moviesCount); }