コード例 #1
0
        public async Task FindByIdAync_MillaJovovich_Returns_ExpectedValues()
        {
            const string expectedName         = "Milla Jovovich";
            const string expectedBiography    = "Milla Jovovich, born as Milica Natasha Jovovich, is an Ukrainian-born actress, an American supermodel, musician, and fashion designer."; // truncated
            DateTime     expectedBirthday     = DateTime.Parse("1975-12-17");
            const Gender expectedGender       = Gender.Female;
            const string expectedHomepage     = "http://www.millaj.com";
            const string expectedImdbId       = "nm0000170";
            const string expectedPlaceOfBirth = "Kiev, Ukraine";

            ApiQueryResponse <Person> response = await _api.FindByIdAsync(PersonId_MillaJovovich);

            ApiResponseUtil.AssertErrorIsNull(response);

            Person person = response.Item;

            Assert.AreEqual(expectedName, person.Name);
            Assert.IsTrue(person.Biography.StartsWith(expectedBiography));
            Assert.IsFalse(person.IsAdultFilmStar);
            Assert.AreEqual(0, person.AlsoKnownAs.Count);
            Assert.AreEqual(expectedBirthday, person.Birthday);
            Assert.AreEqual(expectedGender, person.Gender);
            Assert.AreEqual(null, person.Deathday);
            Assert.AreEqual(expectedHomepage, person.Homepage);
            Assert.AreEqual(expectedImdbId, person.ImdbId);
            Assert.AreEqual(expectedPlaceOfBirth, person.PlaceOfBirth);
            Assert.IsTrue(person.Popularity > 10);
            Assert.IsNotNull(person.ProfilePath);
        }
コード例 #2
0
        public async Task SearchByNameAsync_Milla_Jovovich_Returns_SingleResult_WithExpectedValues()
        {
            const string millaJovovich = "Milla Jovovich";

            ApiSearchResponse <PersonInfo> response = await _api.SearchByNameAsync(millaJovovich);

            ApiResponseUtil.AssertErrorIsNull(response);

            Assert.AreEqual(1, response.TotalResults);
            Assert.AreEqual(1, response.Results.Count);

            PersonInfo person = response.Results.Single();

            Assert.AreEqual(PersonId_MillaJovovich, person.Id);
            Assert.AreEqual(millaJovovich, person.Name);
            Assert.IsFalse(person.IsAdultFilmStar);
            Assert.AreEqual(3, person.KnownFor.Count);

            string[] roles =
            {
                "The Fifth Element",
                "Resident Evil: Retribution",
                "Resident Evil",
            };

            foreach (string role in roles)
            {
                PersonInfoRole info = person.KnownFor.SingleOrDefault(x => x.MovieTitle == role);
                Assert.IsNotNull(info);
                Assert.AreEqual(MediaType.Movie, info.MediaType);
            }
        }
        public async Task GetCreditsAsync_ReturnsCrewMembers()
        {
            const int tvShowRunLolaRun = 106159;

            ApiQueryResponse <TVShowEpisodeCredit> response = await _api.GetCreditsAsync(tvShowRunLolaRun, 1, 1);


            ApiResponseUtil.AssertErrorIsNull(response);

            TVShowEpisodeCredit credit = response.Item;

            TVShowEpisodeCrewMember director = credit.CrewMembers.Single(x => x.Job == "Director");

            Assert.AreEqual(37948, director.PersonId);
            Assert.AreEqual("6041cbd4b77d4b004488e000", director.CreditId);
            Assert.AreEqual("Directing", director.Department);
            Assert.AreEqual("Brad Anderson", director.Name);

            foreach (TVShowEpisodeCrewMember crewMember in credit.CrewMembers)
            {
                Assert.IsTrue(crewMember.PersonId > 0);
                Assert.IsFalse(string.IsNullOrWhiteSpace(crewMember.CreditId));
                Assert.IsFalse(string.IsNullOrWhiteSpace(crewMember.Department));
                Assert.IsFalse(string.IsNullOrWhiteSpace(crewMember.Job));
                Assert.IsFalse(string.IsNullOrWhiteSpace(crewMember.Name));
            }
        }
コード例 #4
0
        public async Task FindByIdAsync_KevinBacon_Returns_ExpectedValues()
        {
            const string expectedName         = "Kevin Bacon";
            const string expectedBiography    = "Kevin Norwood Bacon (born July 8, 1958) is an American film and theater actor"; // truncated
            DateTime     expectedBirthday     = DateTime.Parse("1958-07-08");
            const Gender expectedGender       = Gender.Male;
            const string expectedHomepage     = "http://www.baconbros.com";
            const string expectedImdbId       = "nm0000102";
            const string expectedPlaceOfBirth = "Philadelphia, Pennsylvania, USA";

            string[] alsoKnownAs =
            {
                "Kevin Norwood Bacon",
            };

            ApiQueryResponse <Person> response = await _api.FindByIdAsync(PersonId_KevinBacon);

            ApiResponseUtil.AssertErrorIsNull(response);

            Person person = response.Item;

            Assert.AreEqual(expectedName, person.Name);
            Assert.IsTrue(person.Biography.StartsWith(expectedBiography), $"Actual Biography: {person.Biography}");
            Assert.IsFalse(person.IsAdultFilmStar);
            Assert.AreEqual(expectedBirthday, person.Birthday);
            Assert.AreEqual(expectedGender, person.Gender);
            Assert.AreEqual(null, person.Deathday);
            Assert.AreEqual(expectedHomepage, person.Homepage);
            Assert.AreEqual(expectedImdbId, person.ImdbId);
            Assert.AreEqual(expectedPlaceOfBirth, person.PlaceOfBirth);
            Assert.IsTrue(person.Popularity > 3);
            Assert.IsNotNull(person.ProfilePath);

            CollectionAssert.AreEquivalent(alsoKnownAs, person.AlsoKnownAs.ToArray());
        }
        public async Task GetCreditsAsync_ReturnsCrewMembers()
        {
            const int movieIdRunLolaRun = 104;

            ApiQueryResponse <MovieCredit> response = await _api.GetCreditsAsync(movieIdRunLolaRun);

            ApiResponseUtil.AssertErrorIsNull(response);

            MovieCredit credit = response.Item;

            MovieCrewMember director = credit.CrewMembers.Single(x => x.Job == "Director");

            Assert.AreEqual(1071, director.PersonId);
            Assert.AreEqual("52fe4218c3a36847f80038ab", director.CreditId);
            Assert.AreEqual("Directing", director.Department);
            Assert.AreEqual("Tom Tykwer", director.Name);

            foreach (MovieCrewMember crewMember in credit.CrewMembers)
            {
                Assert.IsTrue(crewMember.PersonId > 0);
                Assert.IsFalse(string.IsNullOrWhiteSpace(crewMember.CreditId));
                Assert.IsFalse(string.IsNullOrWhiteSpace(crewMember.Department));
                Assert.IsFalse(string.IsNullOrWhiteSpace(crewMember.Job));
                Assert.IsFalse(string.IsNullOrWhiteSpace(crewMember.Name));
            }
        }
        public async Task GetCreditsAsync_ReturnsCastMembers()
        {
            const int movieIdRunLolaRun = 104;

            ApiQueryResponse <MovieCredit> response = await _api.GetCreditsAsync(movieIdRunLolaRun);

            ApiResponseUtil.AssertErrorIsNull(response);

            MovieCredit credit = response.Item;

            MovieCastMember lola = credit.CastMembers.Single(x => x.Character == "Lola");

            Assert.AreEqual(679, lola.PersonId);
            Assert.AreEqual(11, lola.CastId);
            Assert.AreEqual("52fe4218c3a36847f80038df", lola.CreditId);
            Assert.AreEqual("Franka Potente", lola.Name);

            foreach (MovieCastMember castMember in credit.CastMembers)
            {
                Assert.IsTrue(castMember.PersonId > 0);
                Assert.IsTrue(castMember.CastId > 0);
                Assert.IsFalse(string.IsNullOrWhiteSpace(castMember.CreditId));
                Assert.IsFalse(string.IsNullOrWhiteSpace(castMember.Name));
                Assert.IsFalse(string.IsNullOrWhiteSpace(castMember.Character));
            }
        }
        public async Task GetCreditsAsync_ReturnsGuestStarsMembers()
        {
            const int tvShowRunLolaRun = 106159;

            ApiQueryResponse <TVShowEpisodeCredit> response = await _api.GetCreditsAsync(tvShowRunLolaRun, 1, 1);


            ApiResponseUtil.AssertErrorIsNull(response);

            TVShowEpisodeCredit credit = response.Item;

            TVShowEpisodeGuestStarsMember member = credit.GuestStarsMembers.Single(x => x.Character == "Isla Vandeberg");

            Assert.AreEqual(1272883, member.PersonId);
            Assert.AreEqual("041caaf5690b50045ea29ae", member.CreditId);
            Assert.AreEqual("Alisha Newton", member.Name);

            foreach (TVShowEpisodeGuestStarsMember guestStarsMember in credit.GuestStarsMembers)
            {
                Assert.IsTrue(guestStarsMember.PersonId > 0);
                Assert.IsFalse(string.IsNullOrWhiteSpace(guestStarsMember.CreditId));
                Assert.IsFalse(string.IsNullOrWhiteSpace(guestStarsMember.Name));
                Assert.IsFalse(string.IsNullOrWhiteSpace(guestStarsMember.Character));
            }
        }
コード例 #8
0
        public async Task GetLatestAsync_Returns_ValidResult()
        {
            ApiQueryResponse <Movie> response = await _api.GetLatestAsync();

            ApiResponseUtil.AssertErrorIsNull(response);

            ApiResponseUtil.AssertMovieStructure(response.Item);
        }
コード例 #9
0
        public async Task GetUpcomingAsync_Returns_ValidResults()
        {
            ApiSearchResponse <Movie> response = await _api.GetUpcomingAsync();

            ApiResponseUtil.AssertErrorIsNull(response);

            ApiResponseUtil.AssertMovieStructure(response.Results);
        }
コード例 #10
0
        public async Task GetTelevisionAsync_Returns_16_Results()
        {
            ApiQueryResponse <IReadOnlyList <Genre> > response = await _api.GetTelevisionAsync();

            ApiResponseUtil.AssertErrorIsNull(response);

            Assert.IsTrue(response.Item.Any());

            Assert.AreEqual(16, response.Item.Count);
        }
コード例 #11
0
        public async Task GetAllAsync_Returns_Known_Genres()
        {
            ApiQueryResponse <IReadOnlyList <Genre> > response = await _api.GetAllAsync();

            ApiResponseUtil.AssertErrorIsNull(response);

            IReadOnlyList <Genre> knownGenres = GenreFactory.GetAll();

            CollectionAssert.AreEquivalent(knownGenres.ToList(), response.Item.ToList());
        }
コード例 #12
0
        public async Task GetPopularAsync_Returns_ValidResults()
        {
            ApiSearchResponse <MovieInfo> response = await _api.GetPopularAsync();

            ApiResponseUtil.AssertErrorIsNull(response);

            IReadOnlyList <MovieInfo> results = response.Results;

            ApiResponseUtil.AssertMovieInformationStructure(results);
        }
コード例 #13
0
        public async Task SearchByNameAsync_The_Nanny_Returns_ExpectedResults_InGerman()
        {
            const string theNanny = "Die Nanny";

            ApiSearchResponse <TVShowInfo> response = await _api.SearchByNameAsync(theNanny, language : "de");

            ApiResponseUtil.AssertErrorIsNull(response);

            AssertTheNanny(response, theNanny);
        }
コード例 #14
0
        public async Task GetTopRatedAsync_Returns_ValidResult()
        {
            ApiSearchResponse <TVShowInfo> response = await _api.GetTopRatedAsync();

            ApiResponseUtil.AssertErrorIsNull(response);

            IReadOnlyList <TVShowInfo> results = response.Results;

            ApiResponseUtil.AssertTVShowInformationStructure(results);
        }
コード例 #15
0
        public async Task MovieWithLargeRevenue_Will_Deserialize()
        {
            const int    id            = 19995;
            const string expectedTitle = "Avatar";

            ApiQueryResponse <Movie> response = await _api.FindByIdAsync(id);

            ApiResponseUtil.AssertErrorIsNull(response);

            Assert.AreEqual(expectedTitle, response.Item.Title);
            Assert.IsTrue(response.Item.Revenue > int.MaxValue);
        }
コード例 #16
0
        private void AssertReponseIncludesJson(ApiResponseBase response)
        {
            string actualJson = $"Actual: {response.Json}";

            ApiResponseUtil.AssertErrorIsNull(response);

            Assert.IsTrue(response.Json.Contains("\"release_date\":\"1998-08-20\""), actualJson);
            Assert.IsTrue(response.Json.Contains("\"original_title\":\"Lola rennt\""), actualJson);
            Assert.IsTrue(response.Json.Contains("\"title\":\"Run Lola Run\""), actualJson);
            Assert.IsTrue(response.Json.Contains("\"original_language\":\"de\""), actualJson);
            Assert.IsTrue(response.Json.Contains("\"id\":104"), actualJson);
        }
        public async Task GetCreditsAsync_Returns_ValidResults()
        {
            const int movieIdRunLolaRun = 104;

            ApiQueryResponse <MovieCredit> response = await _api.GetCreditsAsync(movieIdRunLolaRun);

            ApiResponseUtil.AssertErrorIsNull(response);

            Assert.AreEqual(movieIdRunLolaRun, response.Item.MovieId);
            Assert.AreEqual(23, response.Item.CastMembers.Count);
            Assert.AreEqual(37, response.Item.CrewMembers.Count);
        }
コード例 #18
0
        public async Task GetLatestAsync_Returns_ValidResult()
        {
            ApiQueryResponse <TVShow> response = await _api.GetLatestAsync();

            ApiResponseUtil.AssertErrorIsNull(response);

            TVShow show = response.Item;

            Assert.IsNotNull(show);

            Assert.IsTrue(show.Id > 0);
            Assert.IsFalse(string.IsNullOrEmpty(show.Name));
        }
コード例 #19
0
        public async Task GetAllAsync_Returns_AllResults_With_Id_and_Name()
        {
            ApiQueryResponse <IReadOnlyList <Genre> > response = await _api.GetAllAsync();

            ApiResponseUtil.AssertErrorIsNull(response);

            foreach (Genre genre in response.Item)
            {
                Assert.IsTrue(genre.Id > 0, genre.ToString());
                Assert.IsNotNull(genre.Name, genre.ToString());
                Assert.IsTrue(genre.Name.Length >= 3, genre.ToString());
            }
        }
コード例 #20
0
        public async Task FindByIdAsync_Returns_German_With_LanguageParameter()
        {
            const int    id            = 140607;
            const string language      = "de";
            const string expectedTitle = "Star Wars: Das Erwachen der Macht";

            ApiQueryResponse <Movie> response = await _api.FindByIdAsync(id, language);

            ApiResponseUtil.AssertErrorIsNull(response);

            Assert.AreEqual(id, response.Item.Id);
            Assert.AreEqual(expectedTitle, response.Item.Title);
        }
コード例 #21
0
        public async Task GetCreditsAsync_Returns_ValidResults()
        {
            const int tvShowRunLolaRun = 106159;


            ApiQueryResponse <TVShowEpisodeCredit> response = await _api.GetCreditsAsync(tvShowRunLolaRun, 1, 1);

            ApiResponseUtil.AssertErrorIsNull(response);

            //Assert.AreEqual(tvShowRunLolaRun, response.Item.TVShowEpisodeId );
            Assert.AreEqual(4, response.Item.CastMembers.Count);
            Assert.AreEqual(11, response.Item.CrewMembers.Count);
            Assert.AreEqual(29, response.Item.GuestStarsMembers.Count);
        }
コード例 #22
0
        public async Task GetTelevisionAsync_IsSubset_OfGetAll()
        {
            ApiQueryResponse <IReadOnlyList <Genre> > tv = await _api.GetTelevisionAsync();

            ApiResponseUtil.AssertErrorIsNull(tv);

            ApiQueryResponse <IReadOnlyList <Genre> > all = await _api.GetAllAsync();

            ApiResponseUtil.AssertErrorIsNull(all);

            Assert.IsTrue(all.Item.Count > tv.Item.Count);

            CollectionAssert.IsSubsetOf(tv.Item.ToList(), all.Item.ToList());
        }
コード例 #23
0
        public async Task ApiQueryResponse_Includes_CommandText()
        {
            const string command = "configuration";

            ApiQueryResponse <ApiConfiguration> response = await _api.QueryAsync <ApiConfiguration>(command);

            ApiResponseUtil.AssertErrorIsNull(response);

            string actualCommandText = $"Actual: {response.CommandText}";

            Assert.IsTrue(response.CommandText.Contains(command), actualCommandText);
            Assert.IsTrue(response.CommandText.Contains(AssemblyInit.Settings.ApiKey), actualCommandText);
            Assert.IsTrue(response.CommandText.Contains(AssemblyInit.Settings.ApiUrl), actualCommandText);
        }
コード例 #24
0
        public async Task ApiSearchAsyncResponse_Includes_Json()
        {
            const string command = "search/movie";

            var param = new Dictionary <string, string>
            {
                { "query", "Run Lola Run" },
            };

            ApiSearchResponse <MovieInfo> response = await _api.SearchAsync <MovieInfo>(command, param);

            ApiResponseUtil.AssertErrorIsNull(response);

            AssertReponseIncludesJson(response);
        }
コード例 #25
0
        public async Task GetMovieRatingsAsync_Returns_Ratings_InCorrectOrder()
        {
            ApiQueryResponse <MovieRatings> response = await _api.GetMovieRatingsAsync();

            ApiResponseUtil.AssertErrorIsNull(response);

            AssertOrderedRatings(8, response.Item.Australia);
            AssertOrderedRatings(5, response.Item.Canada);
            AssertOrderedRatings(5, response.Item.France);
            AssertOrderedRatings(5, response.Item.Germany);
            AssertOrderedRatings(3, response.Item.India);
            AssertOrderedRatings(8, response.Item.NewZealand);
            AssertOrderedRatings(7, response.Item.UnitedKingdom);
            AssertOrderedRatings(6, response.Item.UnitedStates);
        }
コード例 #26
0
        public async Task FindMoviesByIdAsync_Returns_ValidResult()
        {
            int genreId = GenreFactory.Comedy().Id;

            ApiSearchResponse <MovieInfo> response = await _api.FindMoviesByIdAsync(genreId);

            ApiResponseUtil.AssertErrorIsNull(response);

            Assert.AreEqual(20, response.Results.Count);

            var expectedGenres = new[] { GenreFactory.Comedy() };

            foreach (MovieInfo info in response.Results)
            {
                CollectionAssert.IsSubsetOf(expectedGenres, info.Genres.ToList());
            }
        }
コード例 #27
0
        public async Task SearchByNameAsync_GameOfThrones_Returns_PopulatedGenres()
        {
            const string query = "Game of Thrones";

            ApiSearchResponse <TVShowInfo> response = await _api.SearchByNameAsync(query);

            ApiResponseUtil.AssertErrorIsNull(response);

            TVShowInfo gameOfThrones = response.Results.Single();

            Genre[] expGenres =
            {
                GenreFactory.SciFiAndFantasy(),
                GenreFactory.ActionAndAdventure(),
                GenreFactory.Drama(),
            };

            CollectionAssert.AreEquivalent(expGenres, gameOfThrones.Genres.ToArray());
        }
コード例 #28
0
        public async Task FindByIdAsync_Pixar_IncludesParentCompany()
        {
            const int    id                 = 3;
            const string expectedName       = "Pixar";
            const string expectedParentName = "Walt Disney Pictures";
            const int    expectedParentId   = 2;

            ApiQueryResponse <ProductionCompany> response = await _api.FindByIdAsync(id);

            ApiResponseUtil.AssertErrorIsNull(response);

            Assert.AreEqual(id, response.Item.Id);
            Assert.AreEqual(expectedName, response.Item.Name);

            Assert.IsNotNull(response.Item.ParentCompany);
            Assert.AreEqual(expectedParentId, response.Item.ParentCompany.Id);
            Assert.AreEqual(expectedParentName, response.Item.ParentCompany.Name);
            ApiResponseUtil.AssertImagePath(response.Item.ParentCompany.LogoPath);
        }
コード例 #29
0
        public async Task FindByIdAsync_Lucasfilm_WithResults_NoParentCompany()
        {
            const int    id                   = 1;
            const string expectedName         = "Lucasfilm Ltd.";
            const string expectedHeadquarters = "San Francisco, California";
            const string expectedHomepage     = "https://www.lucasfilm.com";

            ApiQueryResponse <ProductionCompany> response = await _api.FindByIdAsync(id);

            ApiResponseUtil.AssertErrorIsNull(response);

            Assert.AreEqual(id, response.Item.Id);
            Assert.AreEqual(expectedName, response.Item.Name);
            Assert.AreEqual(expectedHeadquarters, response.Item.Headquarters);
            Assert.AreEqual(new Uri(expectedHomepage), new Uri(response.Item.Homepage));
            ApiResponseUtil.AssertImagePath(response.Item.LogoPath);

            Assert.IsNull(response.Item.ParentCompany);
        }
コード例 #30
0
        public async Task FindById_Returns_Foreign_Genre_NotInGetAll()
        {
            const int    id   = 10769;
            const string name = "Foreign";

            CollectionAssert.DoesNotContain(_api.AllGenres.ToList(), new Genre(id, name));

            // FindById will add to AllGenres when it does not exist
            ApiQueryResponse <Genre> response = await _api.FindByIdAsync(id);

            ApiResponseUtil.AssertErrorIsNull(response);

            Genre genre = response.Item;

            Assert.AreEqual(id, genre.Id);
            Assert.AreEqual(name, genre.Name);

            CollectionAssert.Contains(_api.AllGenres.ToList(), new Genre(id, name));
            CollectionAssert.Contains(_api.AllGenres.ToList(), genre);
        }