Ejemplo n.º 1
0
        public async Task TestCompaniesMoviesAsync()
        {
            //GetCompanyMoviesAsync(int id, string language, int page = -1)
            SearchContainerWithId <SearchMovie> resp = await TMDbClient.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox);

            SearchContainerWithId <SearchMovie> respPage2 = await TMDbClient.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox, 2);

            SearchContainerWithId <SearchMovie> respItalian = await TMDbClient.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox, "it");

            Assert.NotEmpty(resp.Results);
            Assert.NotEmpty(respPage2.Results);
            Assert.NotEmpty(respItalian.Results);

            bool allTitlesIdentical = true;

            for (int index = 0; index < resp.Results.Count; index++)
            {
                Assert.Equal(resp.Results[index].Id, respItalian.Results[index].Id);

                if (resp.Results[index].Title != respItalian.Results[index].Title)
                {
                    allTitlesIdentical = false;
                }
            }

            Assert.False(allTitlesIdentical);
        }
Ejemplo n.º 2
0
        public void TestGenreMovies()
        {
            // Ignore missing json
            IgnoreMissingJson("results[array] / media_type");

            // Get first genre
            Genre genre = Config.Client.GetMovieGenresAsync().Sync().First();

            // Get movies
            SearchContainerWithId <SearchMovie> movies      = Config.Client.GetGenreMoviesAsync(genre.Id).Result;
            SearchContainerWithId <SearchMovie> moviesPage2 = Config.Client.GetGenreMoviesAsync(genre.Id, "it", 2, includeAllMovies: false).Result;
            SearchContainerWithId <SearchMovie> moviesAll   = Config.Client.GetGenreMoviesAsync(genre.Id, includeAllMovies: true).Result;

            Assert.Equal(1, movies.Page);
            Assert.Equal(2, moviesPage2.Page);
            Assert.Equal(1, moviesAll.Page);

            Assert.True(movies.Results.Count > 0);
            Assert.True(moviesPage2.Results.Count > 0);
            Assert.True(moviesAll.Results.Count > 0);

            Assert.True(movies.Results.All(s => s != null));
            Assert.True(moviesPage2.Results.All(s => s != null));
            Assert.True(moviesAll.Results.All(s => s != null));

            Assert.Equal(movies.TotalResults, moviesPage2.TotalResults);     // Should be the same, despite the use of 'includeAllMovies' and Italian
            Assert.True(moviesAll.TotalResults >= movies.TotalResults);
        }
Ejemplo n.º 3
0
        public void TestCompaniesGetters()
        {
            //GetCompanyMovies(int id, string language, int page = -1)
            SearchContainerWithId <MovieResult> resp        = _config.Client.GetCompanyMovies(TwentiethCenturyFox);
            SearchContainerWithId <MovieResult> respPage2   = _config.Client.GetCompanyMovies(TwentiethCenturyFox, 2);
            SearchContainerWithId <MovieResult> respItalian = _config.Client.GetCompanyMovies(TwentiethCenturyFox, "it");

            Assert.IsNotNull(resp);
            Assert.IsNotNull(respPage2);
            Assert.IsNotNull(respItalian);

            Assert.IsTrue(resp.Results.Count > 0);
            Assert.IsTrue(respPage2.Results.Count > 0);
            Assert.IsTrue(respItalian.Results.Count > 0);

            bool allTitlesIdentical = true;

            for (int index = 0; index < resp.Results.Count; index++)
            {
                Assert.AreEqual(resp.Results[index].Id, respItalian.Results[index].Id);

                if (resp.Results[index].Title != respItalian.Results[index].Title)
                {
                    allTitlesIdentical = false;
                }
            }

            Assert.IsFalse(allTitlesIdentical);
        }
Ejemplo n.º 4
0
        public void TestGenreMovies()
        {
            // Get first genre
            Genre genre = _config.Client.GetGenres().First();

            // Get movies
            SearchContainerWithId <MovieResult> movies      = _config.Client.GetGenreMovies(genre.Id);
            SearchContainerWithId <MovieResult> moviesPage2 = _config.Client.GetGenreMovies(genre.Id, "it", 2, includeAllMovies: false);
            SearchContainerWithId <MovieResult> moviesAll   = _config.Client.GetGenreMovies(genre.Id, includeAllMovies: true);

            Assert.AreEqual(1, movies.Page);
            Assert.AreEqual(2, moviesPage2.Page);
            Assert.AreEqual(1, moviesAll.Page);

            Assert.IsTrue(movies.Results.Count > 0);
            Assert.IsTrue(moviesPage2.Results.Count > 0);
            Assert.IsTrue(moviesAll.Results.Count > 0);

            Assert.IsTrue(movies.Results.All(s => s != null));
            Assert.IsTrue(moviesPage2.Results.All(s => s != null));
            Assert.IsTrue(moviesAll.Results.All(s => s != null));

            Assert.AreEqual(movies.TotalResults, moviesPage2.TotalResults);     // Should be the same, despite the use of 'includeAllMovies' and Italian
            Assert.IsTrue(moviesAll.TotalResults >= movies.TotalResults);
        }
Ejemplo n.º 5
0
        public void TestCompaniesGetters()
        {
            // Ignore missing json
            IgnoreMissingJson("results[array] / media_type");

            //GetCompanyMoviesAsync(int id, string language, int page = -1)
            SearchContainerWithId <SearchMovie> resp        = Config.Client.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox).Result;
            SearchContainerWithId <SearchMovie> respPage2   = Config.Client.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox, 2).Result;
            SearchContainerWithId <SearchMovie> respItalian = Config.Client.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox, "it").Result;

            Assert.NotNull(resp);
            Assert.NotNull(respPage2);
            Assert.NotNull(respItalian);

            Assert.True(resp.Results.Count > 0);
            Assert.True(respPage2.Results.Count > 0);
            Assert.True(respItalian.Results.Count > 0);

            bool allTitlesIdentical = true;

            for (int index = 0; index < resp.Results.Count; index++)
            {
                Assert.Equal(resp.Results[index].Id, respItalian.Results[index].Id);

                if (resp.Results[index].Title != respItalian.Results[index].Title)
                {
                    allTitlesIdentical = false;
                }
            }

            Assert.False(allTitlesIdentical);
        }
Ejemplo n.º 6
0
        public async Task <SearchContainerWithId <SearchMovie> > GetGenreMoviesAsync(int genreId, string language, int page = 0, bool?includeAllMovies = null, CancellationToken cancellationToken = default)
        {
            RestRequest req = _client.Create("genre/{genreId}/movies");

            req.AddUrlSegment("genreId", genreId.ToString());

            language ??= DefaultLanguage;
            if (!string.IsNullOrWhiteSpace(language))
            {
                req.AddParameter("language", language);
            }

            if (page >= 1)
            {
                req.AddParameter("page", page.ToString());
            }
            if (includeAllMovies.HasValue)
            {
                req.AddParameter("include_all_movies", includeAllMovies.Value ? "true" : "false");
            }

            SearchContainerWithId <SearchMovie> resp = await req.GetOfT <SearchContainerWithId <SearchMovie> >(cancellationToken).ConfigureAwait(false);

            return(resp);
        }
Ejemplo n.º 7
0
        public void TestKeywordMovies()
        {
            // Ignore missing json
            IgnoreMissingJson("results[array] / media_type");

            KeywordsContainer keywords = Config.Client.GetMovieKeywordsAsync(IdHelper.AGoodDayToDieHard).Result;

            Assert.NotNull(keywords);
            Assert.NotNull(keywords.Keywords);
            Assert.True(keywords.Keywords.Count > 0);

            // Get first keyword
            Keyword testKeyword = keywords.Keywords.First();

            // Get movies
            SearchContainerWithId <SearchMovie> movies        = Config.Client.GetKeywordMoviesAsync(testKeyword.Id).Result;
            SearchContainerWithId <SearchMovie> moviesItalian = Config.Client.GetKeywordMoviesAsync(testKeyword.Id, "it").Result;
            SearchContainerWithId <SearchMovie> moviesPage2   = Config.Client.GetKeywordMoviesAsync(testKeyword.Id, 2).Result;

            Assert.NotNull(movies);
            Assert.NotNull(moviesItalian);
            Assert.NotNull(moviesPage2);

            Assert.Equal(testKeyword.Id, movies.Id);
            Assert.Equal(testKeyword.Id, moviesItalian.Id);
            Assert.Equal(testKeyword.Id, moviesPage2.Id);

            Assert.True(movies.Results.Count > 0);
            Assert.True(moviesItalian.Results.Count > 0);

            if (movies.TotalResults > movies.Results.Count)
            {
                Assert.True(moviesPage2.Results.Count > 0);
            }
            else
            {
                Assert.Equal(0, moviesPage2.Results.Count);
            }

            Assert.Equal(1, movies.Page);
            Assert.Equal(1, moviesItalian.Page);
            Assert.Equal(2, moviesPage2.Page);

            // All titles on page 1 must be the same
            bool allTitlesIdentical = true;

            for (int index = 0; index < movies.Results.Count; index++)
            {
                Assert.Equal(movies.Results[index].Id, moviesItalian.Results[index].Id);

                // At least one title must differ in title
                if (movies.Results[index].Title != moviesItalian.Results[index].Title)
                {
                    allTitlesIdentical = false;
                }
            }

            Assert.False(allTitlesIdentical);
        }
Ejemplo n.º 8
0
        public async void TestMoviesGetMovieReviews()
        {
            SearchContainerWithId <ReviewBase> resp = await TMDbClient.GetMovieReviewsAsync(IdHelper.AGoodDayToDieHard);

            ReviewBase single = resp.Results.Single(s => s.Id == "5ae9d7ae0e0a26394e008aeb");

            await Verify(single);
        }
Ejemplo n.º 9
0
        public async Task TestGenreMoviesAsync()
        {
            SearchContainerWithId <SearchMovie> movies = await TMDbClient.GetGenreMoviesAsync(IdHelper.AdventureMovieGenre);

            Assert.NotEmpty(movies.Results);
            Assert.Equal(IdHelper.AdventureMovieGenre, movies.Id);
            Assert.All(movies.Results, x => Assert.Contains(IdHelper.AdventureMovieGenre, x.GenreIds));
        }
Ejemplo n.º 10
0
        public void TestMoviesGetMovieReviews()
        {
            SearchContainerWithId <ReviewBase> resp = Config.Client.GetMovieReviewsAsync(IdHelper.TheDarkKnightRises).Result;

            Assert.NotNull(resp);

            Assert.NotEqual(0, resp.Results.Count);
            Assert.NotNull(resp.Results[0].Content);
        }
Ejemplo n.º 11
0
        public async void TestMoviesGetMovieLists()
        {
            await TestHelpers.SearchPagesAsync <SearchContainerWithId <ListResult>, ListResult>(page => TMDbClient.GetMovieListsAsync(IdHelper.AGoodDayToDieHard, page));

            SearchContainerWithId <ListResult> resp = await TMDbClient.GetMovieListsAsync(IdHelper.AGoodDayToDieHard);

            Assert.Equal(IdHelper.AGoodDayToDieHard, resp.Id);
            Assert.NotEmpty(resp.Results);
        }
Ejemplo n.º 12
0
        public async Task TestTvShowReviews()
        {
            await TestHelpers.SearchPagesAsync <SearchContainerWithId <ReviewBase>, ReviewBase>(i => TMDbClient.GetTvShowReviewsAsync(IdHelper.BreakingBad, page: i));

            SearchContainerWithId <ReviewBase> reviews = await TMDbClient.GetTvShowReviewsAsync(IdHelper.BreakingBad);

            ReviewBase single = reviews.Results.Single(s => s.Id == "5accdbe6c3a3687e2702d058");

            await Verify(single);
        }
Ejemplo n.º 13
0
        public async Task TestKeywordMovies()
        {
            SearchContainerWithId <SearchMovie> movies = await TMDbClient.GetKeywordMoviesAsync(IdHelper.AgentKeyword);

            Assert.Equal(IdHelper.AgentKeyword, movies.Id);
            Assert.NotEmpty(movies.Results);

            KeywordsContainer movie = await TMDbClient.GetMovieKeywordsAsync(movies.Results.First().Id);

            Assert.Contains(movie.Keywords, x => IdHelper.AgentKeyword == x.Id);
        }
Ejemplo n.º 14
0
        public void TestJsonTaggedImageConverter()
        {
            // Get images
            SearchContainerWithId <TaggedImage> result = Config.Client.GetPersonTaggedImagesAsync(IdHelper.HughLaurie, 1).Sync();

            Assert.NotNull(result);
            Assert.NotNull(result.Results);
            Assert.Equal(IdHelper.HughLaurie, result.Id);

            Assert.Contains(result.Results, item => item.MediaType == MediaType.Tv && item.Media is SearchTv);
            Assert.Contains(result.Results, item => item.MediaType == MediaType.Movie && item.Media is SearchMovie);
        }
Ejemplo n.º 15
0
        public void TestMoviesGetMovieLists()
        {
            SearchContainerWithId <ListResult> resp = Config.Client.GetMovieListsAsync(IdHelper.AGoodDayToDieHard).Result;

            Assert.NotNull(resp);
            Assert.Equal(IdHelper.AGoodDayToDieHard, resp.Id);

            SearchContainerWithId <ListResult> respPage2 = Config.Client.GetMovieListsAsync(IdHelper.AGoodDayToDieHard, 2).Result;

            Assert.NotNull(respPage2);

            Assert.Equal(1, resp.Page);
            Assert.Equal(2, respPage2.Page);
            Assert.Equal(resp.TotalResults, resp.TotalResults);
        }
Ejemplo n.º 16
0
        //Map reviews to ReviewTorrentDTO()
        public ReviewTorrentDTO MapReviewToSuggestionTorrentDTO(SearchContainerWithId <ReviewBase> reviewList)
        {
            if (reviewList.TotalResults == 0)
            {
                return(null);
            }

            var torrentList =
                new ReviewTorrentDTO
            {
                Author  = reviewList.Results[0].Author,
                Content = reviewList.Results[0].Content
            };

            return(torrentList);
        }
Ejemplo n.º 17
0
        public void TestJsonTaggedImageConverter()
        {
            // Ignore fields not set
            IgnoreMissingCSharp("_id / _id", "adult / adult", "backdrop_path / backdrop_path", "first_air_date / first_air_date", "genre_ids / genre_ids", "name / name", "origin_country / origin_country", "original_language / original_language", "original_name / original_name", "original_title / original_title", "overview / overview", "poster_path / poster_path", "release_date / release_date", "title / title", "video / video", "vote_average / vote_average", "vote_count / vote_count");
            IgnoreMissingJson(" / media_type");

            // Get images
            SearchContainerWithId <TaggedImage> result = Config.Client.GetPersonTaggedImagesAsync(IdHelper.HughLaurie, 1).Sync();

            Assert.NotNull(result);
            Assert.NotNull(result.Results);
            Assert.Equal(IdHelper.HughLaurie, result.Id);

            Assert.Contains(result.Results, item => item.MediaType == MediaType.Tv && item.Media is SearchTv);
            Assert.Contains(result.Results, item => item.MediaType == MediaType.Movie && item.Media is SearchMovie);
        }
Ejemplo n.º 18
0
        public async Task <SearchContainerWithId <SearchMovie> > GetKeywordMoviesAsync(int keywordId, string language, int page = 0, CancellationToken cancellationToken = default)
        {
            RestRequest req = _client.Create("keyword/{keywordId}/movies");

            req.AddUrlSegment("keywordId", keywordId.ToString());

            language ??= DefaultLanguage;
            if (!string.IsNullOrWhiteSpace(language))
            {
                req.AddParameter("language", language);
            }

            if (page >= 1)
            {
                req.AddParameter("page", page.ToString());
            }

            SearchContainerWithId <SearchMovie> resp = await req.GetOfT <SearchContainerWithId <SearchMovie> >(cancellationToken).ConfigureAwait(false);

            return(resp);
        }
Ejemplo n.º 19
0
        public async Task TestJsonTaggedImageConverter()
        {
            // Get images
            SearchContainerWithId <TaggedImage> result = await TMDbClient.GetPersonTaggedImagesAsync(IdHelper.HughLaurie, 1);

            Assert.NotNull(result);
            Assert.NotNull(result.Results);
            Assert.Equal(IdHelper.HughLaurie, result.Id);

            Assert.All(result.Results, item =>
            {
                if (item.MediaType == MediaType.Tv)
                {
                    Assert.IsType <SearchTv>(item.Media);
                }
            });
            Assert.All(result.Results, item =>
            {
                if (item.MediaType == MediaType.Movie)
                {
                    Assert.IsType <SearchMovie>(item.Media);
                }
            });
        }