public static void GetAlbumAsync_AccessibleTrack_ReturnsExpectedAlbumDetails()
            {
                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 artist    = random.AddArtist();
                    var album     = random.AddAlbum(artist);
                    var directory = random.AddDirectory(library);
                    var file      = random.AddFile(directory);
                    var track     = random.AddTrack(file, artist, album);
                    dbContext.SaveChanges();

                    string transcodedSuffix = "mp3";
                    var    result           = RestApiQueries.GetAlbumAsync(dbContext, user.UserId, album.AlbumId, transcodedSuffix, CancellationToken.None).GetAwaiter().GetResult();

                    var tracks = new[] { track };

                    Assert.Equal("a" + album.AlbumId, result.id);
                    Assert.Equal(album.Title, result.name);
                    Assert.Equal(album.Artist.Name, result.artist);
                    Assert.Equal("r" + artist.ArtistId, result.artistId);
                    Assert.Equal(album.CoverPictureId?.ToString("X8"), result.coverArt);
                    Assert.Equal(tracks.Count(), result.songCount);
                    Assert.Equal(Math.Round(tracks.Sum(t => t.Duration) ?? 0), result.duration);
                    Assert.False(result.playCountSpecified);
                    Assert.Equal(default, result.playCount);
            public static void GetAlbumAsync_NoAccessibleTrack_ThrowsDataNotFoundError()
            {
                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(accessControlled: true);
                    var artist    = random.AddArtist();
                    var album     = random.AddAlbum(artist);
                    var directory = random.AddDirectory(library);
                    var file      = random.AddFile(directory);
                    var track     = random.AddTrack(file, artist, album);
                    dbContext.SaveChanges();

                    string transcodedSuffix = "mp3";
                    var    ex = Assert.Throws <RestApiErrorException>(() => RestApiQueries.GetAlbumAsync(dbContext, user.UserId, album.AlbumId, transcodedSuffix, CancellationToken.None).GetAwaiter().GetResult());

                    var expectedException = RestApiErrorException.DataNotFoundError();
                    Assert.Equal(expectedException.Message, ex.Message);
                    Assert.Equal(expectedException.Code, ex.Code);
                }
            }