Exemplo n.º 1
0
        private async Task <Series> GetSeriesInfo(ISeriesIdentifier seriesIdentifier, string authToken,
                                                  IWebProxy proxyPreferences)
        {
            Task <string> getSeriesTask       = _apiDownloader.GetSeriesAsync(seriesIdentifier, authToken, proxyPreferences);
            Task <string> getSeriesImagesTask =
                _apiDownloader.GetSeriesImagesAsync(seriesIdentifier, authToken, proxyPreferences);

            await Task.WhenAll(getSeriesTask, getSeriesImagesTask);

            string seriesJson = getSeriesTask.Result;
            TheTvDbSeriesResult seriesResults = JsonConvert.DeserializeObject <TheTvDbSeriesResult>(seriesJson);

            string imagesJson = getSeriesImagesTask.Result;
            TheTvDbSeriesImageResults imageResults =
                JsonConvert.DeserializeObject <TheTvDbSeriesImageResults>(imagesJson);

            Series series = Adapt(seriesResults.Data, imageResults);

            return(series);
        }
        public async Task ShouldProduceSeriesInfo()
        {
            // Arrange
            var seriesId  = GetSeriesIdentifier(KnownTvShowIds.StarWarsTheBadBatch);
            var authToken = await GetAuthTokenAsync();

            var sut = CreateDownloader();

            // Act
            var actual = await sut.GetSeriesAsync(seriesId, authToken, null);

            // Assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual, Is.Not.Empty);

            TheTvDbSeriesResult response =
                JsonConvert.DeserializeObject <TheTvDbSeriesResult>(actual);

            Assert.That(response, Is.Not.Null);
            Assert.That(response.Errors, Is.Null | Is.Empty);
            Assert.That(response.Data, Is.Not.Null);
            Assert.That(response.Data.Id, Is.EqualTo((int)KnownTvShowIds.StarWarsTheBadBatch));
        }