public static void TestGetStarred2Async() { var dbConnection = OpenSqliteDatabase(); var dbContextOptionsBuilder = new DbContextOptionsBuilder <MediaInfoContext>() .DisableClientSideEvaluation() .UseSqlite(dbConnection); using (var dbContext = new MediaInfoContext(dbContextOptionsBuilder.Options)) { var random = new RandomPopulator(dbContext); var user = random.AddUser(); var library = random.AddLibrary(); var directory = random.AddDirectory(library); var trackFile = random.AddFile(directory); var genre = random.AddGenre(); var artist = random.AddArtist(); var album = random.AddAlbum(artist); var track = random.AddTrack(trackFile, artist, album, genre: genre); var artistStar = random.AddArtistStar(artist, user); var albumStar = random.AddAlbumStar(album, user); var trackStar = random.AddTrackStar(track, user); dbContext.SaveChanges(); var result = RestApiQueries.GetStarred2Async(dbContext, user.UserId, null, "opus", CancellationToken.None).GetAwaiter().GetResult(); Assert.NotNull(result); // TODO } }
public static void TestUnstarTrackAsync() { var dbConnection = OpenSqliteDatabase(); var dbContextOptionsBuilder = new DbContextOptionsBuilder <MediaInfoContext>() .DisableClientSideEvaluation() .UseSqlite(dbConnection); using (var dbContext = new MediaInfoContext(dbContextOptionsBuilder.Options)) { var random = new RandomPopulator(dbContext); var user = random.AddUser(); var library = random.AddLibrary(); var directory = random.AddDirectory(library); var trackFile = random.AddFile(directory); var artist = random.AddArtist(); var album = random.AddAlbum(artist); var track = random.AddTrack(trackFile, artist, album); var trackStar = random.AddTrackStar(track, user); dbContext.SaveChanges(); for (int i = 0; i < 2; ++i) { RestApiQueries.UnstarTrackAsync(dbContext, user.UserId, track.TrackId, CancellationToken.None).GetAwaiter().GetResult(); dbContext.SaveChanges(); Assert.False(dbContext.TrackStars.Any(s => s.TrackId == track.TrackId && s.UserId == user.UserId)); } } }