public void DeleteByPlaylistId() { var options = new DbContextOptionsBuilder <FlixContext>() .UseInMemoryDatabase(databaseName: "FlixUsersDatabase") .Options; // Use a clean instance of the context to run the test using (var context = new FlixContext(options)) { PlaylistRepository playlistRepo = new PlaylistRepository(context); var playlist = playlistRepo.DeletePlayListById(1); var getAllPlaylist = playlistRepo.GetAllPlaylists(); Assert.AreEqual(4, getAllPlaylist.Count); context.Dispose(); } }