Пример #1
0
        private List <Profile147> QueryItems(IDirectDataMapper db)
        {
            var test = db.Query("SELECT * FROM Profiles");

            var items = db.Query <Profile147>("SELECT FormatItems, FormatCutoff FROM Profiles");

            return(items.Select(i =>
            {
                i.DeserializedItems = JsonConvert.DeserializeObject <List <ProfileFormatItem147> >(i.FormatItems);
                return i;
            }).ToList());
        }
        private void VerifyTracks(IDirectDataMapper db, int albumId, int albumReleaseId, int expectedCount)
        {
            var tracks = db.Query <Track>("SELECT Tracks.* FROM Tracks " +
                                          "JOIN AlbumReleases ON Tracks.AlbumReleaseId = AlbumReleases.Id " +
                                          "JOIN Albums ON AlbumReleases.AlbumId = Albums.Id " +
                                          "WHERE Albums.Id = " + albumId).ToList();

            var album = db.Query <Album>("SELECT * FROM Albums WHERE Albums.Id = " + albumId).ToList().Single();

            tracks.Count.Should().Be(expectedCount);
            tracks.First().AlbumReleaseId.Should().Be(albumReleaseId);
            tracks.All(t => t.ArtistMetadataId == album.ArtistMetadataId).Should().BeTrue();
        }
        private IEnumerable <AlbumRelease> VerifyAlbumReleases(IDirectDataMapper db)
        {
            var releases = db.Query <AlbumRelease>("SELECT * FROM AlbumReleases");
            var albums   = db.Query <Album>("SELECT * FROM Albums");

            // we only put in one release per album
            releases.Count().Should().Be(albums.Count());

            // each album should be linked to exactly one release
            releases.Select(x => x.AlbumId).SequenceEqual(albums.Select(x => x.Id)).Should().Be(true);

            // each release should have at least one medium
            releases.Select(x => x.Media.Count).Min().Should().BeGreaterOrEqualTo(1);

            return(releases);
        }
        private void VerifyTracksFiles(IDirectDataMapper db, int albumId, List <string> expectedPaths)
        {
            var tracks = db.Query("SELECT TrackFiles.* FROM TrackFiles " +
                                  "WHERE TrackFiles.AlbumId = " + albumId);

            TestLogger.Debug($"Got {tracks.Count} tracks");

            tracks.Select(x => x["Path"]).Should().BeEquivalentTo(expectedPaths);
        }
Пример #5
0
        private List <CustomFormatTest149> QueryItems(IDirectDataMapper db)
        {
            var items = db.Query <CustomFormatTest149>("SELECT Name, FormatTags FROM CustomFormats");

            return(items.Select(i =>
            {
                i.DeserializedTags = JsonConvert.DeserializeObject <List <string> >(i.FormatTags);
                return i;
            }).ToList());
        }
Пример #6
0
        private void VerifyArtists(IDirectDataMapper db, List <int> ids)
        {
            var artists = db.Query("SELECT Artists.* from Artists");

            artists.Select(x => x["Id"]).ShouldBeEquivalentTo(ids);

            var duplicates = artists.GroupBy(x => x["ArtistMetadataId"])
                             .Where(x => x.Count() > 1);

            duplicates.Should().BeEmpty();
        }