Example #1
0
        public async Task InvalidApiKey()
        {
            var api = new IntegrationApiRequest(new IntegrationMovieDbSettings("xxx", AssemblyInit.Settings.ApiUrl));

            ApiQueryResponse <InvalidObject> result = await api.QueryAsync <InvalidObject>("junk");

            AssertErrorCode(result, TmdbStatusCode.InvalidApiKey);
        }
        private static void ValidateApiKey()
        {
            ApiQueryResponse <object> response = Task.Run(() =>
            {
                var request = new IntegrationApiRequest(Settings);

                var result = request.QueryAsync <object>(string.Empty);

                return(result);
            }).GetAwaiter().GetResult();

            Assert.IsNull(response.Error, $"{response.Error} Query: {response.CommandText}");
        }
        public async Task SearchByTitleAsync_Excludes_AdultFilms()
        {
            // 2 parts to test:
            // 1. manual search to verify adult films
            // 2. api search to verify no adult films

            const string adultFilmTitle = "Debbie Does Dallas";

            var param = new Dictionary <string, string>
            {
                { "query", adultFilmTitle },
                { "include_adult", "true" },
                { "language", "en" },
            };

            string[] expectedAdultTitles =
            {
                "Debbie Does Dallas",
                "Debbie Does Dallas... Again",
                "Debbie Does Dallas: The Revenge",
                "Debbie Does Dallas Part II",
                "Debbie Does Dallas III: The Final Chapter",
            };

            var integrationApi = new IntegrationApiRequest(AssemblyInit.Settings);

            var adult = await integrationApi.SearchAsync <MovieInfo>("search/movie", param);

            foreach (string title in expectedAdultTitles)
            {
                var adultMovie = adult.Results.SingleOrDefault(x => x.Title == title);
                Assert.IsNotNull(adultMovie);
            }

            ApiSearchResponse <MovieInfo> search = await _api.SearchByTitleAsync(adultFilmTitle);

            // if any results are returned, ensure they are not marked as an adult film
            foreach (MovieInfo movie in search.Results)
            {
                Assert.IsFalse(movie.IsAdultThemed);
            }
        }
 public void TestInit()
 {
     ApiResponseUtil.ThrottleTests();
     _api = new IntegrationApiRequest(AssemblyInit.Settings);
 }