public string SearchMusic(IMusic musicToSearch)
        {
            switch (musicToSearch)
            {
            case Track _:
            {
                YSearch response = yandexMusicClient.Search.Track(yAuthStorage,
                                                                  musicToSearch.QueryString( ))
                                   .Result;
                foreach (YSearchTrackModel ymTrack in response.Tracks.Results)
                {
                    if (musicToSearch.Equals(new Track(ymTrack.Title,
                                                       ymTrack.Artists.First( ).Name,
                                                       ymTrack.Albums.First( ).Title,
                                                       0)))
                    {
                        return(BuildUri(ymTrack));
                    }
                }
                break;
            }

            case Album _:
            {
                YSearch response = yandexMusicClient.Search.Albums(yAuthStorage,
                                                                   musicToSearch.QueryString( ))
                                   .Result;
                foreach (YSearchAlbumModel ymAlbum in response.Albums.Results)
                {
                    if (musicToSearch.Equals(new Album(ymAlbum.Title,
                                                       ymAlbum.Artists.First( ).Name,
                                                       ymAlbum.Year.ToString( ))))
                    {
                        return(BuildUri(ymAlbum));
                    }
                }
                break;
            }

            case Artist artistToSearch:
            {
                YSearch response = yandexMusicClient.Search.Artist(yAuthStorage,
                                                                   musicToSearch.QueryString( ))
                                   .Result;
                foreach (YSearchArtistModel ymArtist in response.Artists.Results)
                {
                    if (string.Equals(artistToSearch.Name, ymArtist.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        var ymArtistBrief = yandexMusicClient.Artist.Get(yAuthStorage,
                                                                         ymArtist.Id)
                                            .Result;
                        foreach (YAlbum ymAlbum in ymArtistBrief.Albums)
                        {
                            if (artistToSearch.SampleAlbum.Equals(new Album(ymAlbum.Title,
                                                                            ymArtist.Name,
                                                                            ymAlbum.Year.ToString( ))))
                            {
                                return(BuildUri(ymArtist));
                            }
                        }
                    }
                }

                break;
            }
            }

            return(null);
        }
Пример #2
0
        public void Playlist_ValidData_True()
        {
            YSearch response = Fixture.Client.Search(playlist, YSearchType.Playlist);

            response.Playlists.Total.Should().BeGreaterThan(0);
        }
Пример #3
0
        public void Video_ValidData_True()
        {
            YSearch response = Fixture.Client.Search(track, YSearchType.Video);

            response.Videos.Total.Should().BeGreaterThan(0);
        }
Пример #4
0
        public void Albums_ValidData_True()
        {
            YSearch response = Fixture.Client.Search(album, YSearchType.Album);

            response.Albums.Total.Should().BeGreaterThan(0);
        }