public void ItReturns_CorrectPocoCollection_FromGenreCollection(GenresCollection genreCollection)
        {
            var genreMapper = new GenresMapper();

            var pocoCollection = genreMapper.Map(genreCollection);

            for (var i = 0; i < genreCollection.Genres.Length; i++)
            {
                Assert.Equal(pocoCollection.ElementAt(i).GenreId, genreCollection.Genres[i].Id);
                Assert.Equal(pocoCollection.ElementAt(i).Name, genreCollection.Genres[i].Name);
            }
        }
        public ICollection <GenrePoco> Map(GenresCollection genres)
        {
            var genresList = new List <GenrePoco>();

            foreach (var genre in genres.Genres)
            {
                genresList.Add(new GenrePoco
                {
                    GenreId = genre.Id,
                    Name    = genre.Name
                });
            }

            return(genresList);
        }
Ejemplo n.º 3
0
        public async Task <GenresCollection> GetGenres()
        {
            var path = FormatPath();

            GenresCollection genres = null;

            while (genres == null)
            {
                var response = await _client.GetAsync(path);

                if (response.IsSuccessStatusCode && response.Content != null)
                {
                    var requestContent = await response.Content.ReadAsStringAsync();

                    genres = JsonConvert.DeserializeObject <GenresCollection>(requestContent);
                }
            }

            return(genres);
        }