using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; using TMDbLib.Objects.Authentication; using TMDbLib.Objects.General; using TMDbLib.Objects.Reviews; using TMDbLib.Objects.Search; using TMDbLib.Objects.TvShows; using TMDbLibTests.Helpers; using TMDbLibTests.JsonHelpers; using Credits = TMDbLib.Objects.TvShows.Credits; namespace TMDbLibTests { public class ClientTvShowTests : TestBase { private static readonly Dictionary> Methods; static ClientTvShowTests() { Methods = new Dictionary> { [TvShowMethods.Credits] = tvShow => tvShow.Credits, [TvShowMethods.Images] = tvShow => tvShow.Images, [TvShowMethods.ExternalIds] = tvShow => tvShow.ExternalIds, [TvShowMethods.ContentRatings] = tvShow => tvShow.ContentRatings, [TvShowMethods.AlternativeTitles] = tvShow => tvShow.AlternativeTitles, [TvShowMethods.Keywords] = tvShow => tvShow.Keywords, [TvShowMethods.Changes] = tvShow => tvShow.Changes, [TvShowMethods.AccountStates] = tvShow => tvShow.AccountStates, [TvShowMethods.Recommendations] = tvShow => tvShow.Recommendations, [TvShowMethods.WatchProviders] = tvShow => tvShow.WatchProviders, [TvShowMethods.EpisodeGroups] = tvShow => tvShow.EpisodeGroups, [TvShowMethods.CreditsAggregate] = tvShow => tvShow.AggregateCredits }; } [Fact] public async Task TestTvShowExtrasNoneAsync() { TvShow tvShow = await TMDbClient.GetTvShowAsync(IdHelper.BreakingBad); await Verify(tvShow); // Test all extras, ensure none of them are populated foreach (Func selector in Methods.Values) Assert.Null(selector(tvShow)); } [Fact] public async Task TestTvShowExtrasAllAsync() { await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession); // Account states will only show up if we've done something await TMDbClient.TvShowSetRatingAsync(IdHelper.KeepingUpAppearances, 5); await TestMethodsHelper.TestGetAll(Methods, combined => TMDbClient.GetTvShowAsync(IdHelper.KeepingUpAppearances, combined), show => Verify(show)); } [Fact] public async Task TestTvShowSeparateExtrasCreditsAsync() { Credits credits = await TMDbClient.GetTvShowCreditsAsync(IdHelper.BreakingBad); await Verify(credits); } [Fact] public async Task TestAggregateCreditsExtractAllAsync() { CreditsAggregate credits = await TMDbClient.GetAggregateCredits(IdHelper.Lupin); await Verify(credits); } [Fact] public async Task TestTvShowSeparateExtrasExternalIdsAsync() { ExternalIdsTvShow externalIds = await TMDbClient.GetTvShowExternalIdsAsync(IdHelper.GameOfThrones); await Verify(externalIds); } [Fact] public async Task TestTvShowSeparateExtrasContentRatingsAsync() { ResultContainer contentRatings = await TMDbClient.GetTvShowContentRatingsAsync(IdHelper.BreakingBad); await Verify(contentRatings); } [Fact] public async Task TestTvShowSeparateExtrasAlternativeTitlesAsync() { ResultContainer alternativeTitles = await TMDbClient.GetTvShowAlternativeTitlesAsync(IdHelper.BreakingBad); await Verify(alternativeTitles); } [Fact] public async Task TestTvShowSeparateExtrasKeywordsAsync() { ResultContainer keywords = await TMDbClient.GetTvShowKeywordsAsync(IdHelper.BreakingBad); Keyword single = keywords.Results.Single(s => s.Id == 15484); await Verify(single); } [Fact] public async Task TestTvShowSeparateExtrasTranslationsAsync() { TranslationsContainerTv translations = await TMDbClient.GetTvShowTranslationsAsync(IdHelper.BreakingBad); Translation single = translations.Translations.Single(s => s.Iso_3166_1 == "DK"); await Verify(single); } [Fact] public async Task TestTvShowSeparateExtrasVideosAsync() { ResultContainer