public void AddMovieToCartShouldAddMovieAndUserToCartMovies() { DbContextOptions <UltimateMoviesDbContext> options = new DbContextOptionsBuilder <UltimateMoviesDbContext>() .UseInMemoryDatabase(databaseName: "Carts_AddMovieToCart_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.SaveChanges(); cartsService.AddMovieToCart(db.Users.ToList()[0].UserName, db.Movies.ToList()[0].Id); int cartMoviesCount = db.CartMovies.ToList().Count(); string cartMoviesUserId = db.CartMovies.ToList()[0].UserId; int cartMoviesMovieId = db.CartMovies.ToList()[0].MovieId; Assert.Equal(1, cartMoviesCount); Assert.Equal(db.Users.ToList()[0].Id, cartMoviesUserId); Assert.Equal(db.Movies.ToList()[0].Id, cartMoviesMovieId); }