コード例 #1
0
        public async Task FindByIdAsync_KevinBacon_Returns_ExpectedValuesIncludingImages()
        {
            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, includeImages : true);

            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 > 2);
            Assert.IsNotNull(person.ProfilePath);

            CollectionAssert.AreEquivalent(alsoKnownAs, person.AlsoKnownAs.ToArray());

            Assert.IsNotNull(person.Profiles);

            Assert.AreNotEqual(0, person.Profiles);

            var profile = person.Profiles[0];

            Assert.AreNotEqual(0, profile.AspectRatio);
            ApiResponseUtil.AssertImagePath(profile.FilePath);
            Assert.AreNotEqual(0, profile.Height);
            Assert.AreNotEqual(0, profile.Width);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
        public async Task FindByIdAsync_StarWarsTheForceAwakens_Returns_AllValues()
        {
            const int    id                       = 140607;
            const string expectedImdbId           = "tt2488496";
            const string expectedTitle            = "Star Wars: The Force Awakens";
            const string expectedOriginalTitle    = "Star Wars: The Force Awakens";
            const string expectedTagline          = "Every generation has a story.";
            const string expetedOverview          = "Thirty years after defeating the Galactic Empire"; // truncated
            const string expectedOriginalLanguage = "en";
            const string expectedHomepage         = "http://www.starwars.com/films/star-wars-episode-vii";
            const string expectedStatus           = "Released";
            const int    expectedBudget           = 200000000;
            const int    expectedRuntime          = 136;
            var          expectedReleaseDate      = new DateTime(2015, 12, 15);

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

            ApiResponseUtil.AssertErrorIsNull(response);

            Movie movie = response.Item;

            Assert.AreEqual(id, movie.Id);
            Assert.AreEqual(expectedImdbId, movie.ImdbId);
            Assert.AreEqual(expectedTitle, movie.Title);
            Assert.AreEqual(expectedOriginalTitle, movie.OriginalTitle);
            Assert.AreEqual(expectedTagline, movie.Tagline);
            Assert.AreEqual(expectedOriginalLanguage, movie.OriginalLanguage);
            Assert.AreEqual(expectedHomepage, movie.Homepage);
            Assert.AreEqual(expectedStatus, movie.Status);
            Assert.AreEqual(expectedBudget, movie.Budget);
            Assert.AreEqual(expectedRuntime, movie.Runtime);
            Assert.AreEqual(expectedReleaseDate, movie.ReleaseDate);

            ApiResponseUtil.AssertImagePath(movie.BackdropPath);
            ApiResponseUtil.AssertImagePath(movie.PosterPath);

            Assert.IsTrue(movie.Overview.StartsWith(expetedOverview));
            Assert.IsTrue(movie.Popularity > 7, $"Actual: {movie.Popularity}");
            Assert.IsTrue(movie.VoteAverage > 5);
            Assert.IsTrue(movie.VoteCount > 1500);

            // Spoken Languages
            var languages = new[]
            {
                new Language("en", "English"),
            };

            CollectionAssert.AreEqual(languages, movie.SpokenLanguages.ToArray());

            // Production Companies
            var companies = new[]
            {
                new ProductionCompanyInfo(1, "Lucasfilm"),
                new ProductionCompanyInfo(1634, "Truenorth Productions"),
                new ProductionCompanyInfo(11461, "Bad Robot"),
            };

            CollectionAssert.AreEquivalent(companies, movie.ProductionCompanies.ToArray());

            // Production Countries
            var countries = new[]
            {
                new Country("US", "United States of America"),
            };

            CollectionAssert.AreEqual(countries, movie.ProductionCountries.ToArray());

            // Movie Collection
            Assert.IsNotNull(movie.MovieCollectionInfo);
            Assert.AreEqual(10, movie.MovieCollectionInfo.Id);
            Assert.AreEqual("Star Wars Collection", movie.MovieCollectionInfo.Name);
            ApiResponseUtil.AssertImagePath(movie.MovieCollectionInfo.BackdropPath);
            ApiResponseUtil.AssertImagePath(movie.MovieCollectionInfo.PosterPath);

            // Genres
            var expectedGenres = new List <Genre>
            {
                GenreFactory.Action(),
                GenreFactory.Adventure(),
                GenreFactory.ScienceFiction(),
                GenreFactory.Fantasy(),
            };

            CollectionAssert.AreEquivalent(expectedGenres, movie.Genres.ToList());

            // Keywords
            var expectedKeywords = new List <Keyword>
            {
                new Keyword(803, "android"),
                new Keyword(9831, "spaceship"),
                new Keyword(10527, "jedi"),
                new Keyword(161176, "space opera"),
                new Keyword(209714, "3d"),
                new Keyword(229031, "shot on imax cameras"),
            };

            CollectionAssert.AreEquivalent(expectedKeywords, movie.Keywords.ToList());
        }
コード例 #5
0
        public async Task FindById_GameOfThrones_ReturnsAllValuesIncludingImages()
        {
            var          expFirstAirDate     = new DateTime(2011, 04, 17);
            const string expHomepage         = "http://www.hbo.com/game-of-thrones";
            const string expName             = "Game of Thrones";
            const string expOriginalLanguage = "en";

            ApiQueryResponse <TVShow> response = await _api.FindByIdAsync(1399, includeImages : true);

            ApiResponseUtil.AssertErrorIsNull(response);

            TVShow show = response.Item;

            TVShowCreator[] expCreatedBy =
            {
                new TVShowCreator(9813,   "David Benioff", "/8CuuNIKMzMUL1NKOPv9AqEwM7og.jpg"),
                new TVShowCreator(228068, "D. B. Weiss",   "/caUAtilEe06OwOjoQY3B7BgpARi.jpg"),
            };

            CollectionAssert.AreEquivalent(expCreatedBy, show.CreatedBy.ToArray());

            var expRunTime = new[] { 60 };

            CollectionAssert.AreEquivalent(expRunTime, show.EpisodeRunTime.ToArray());

            Assert.AreEqual(expFirstAirDate.Date, show.FirstAirDate.Date);

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

            CollectionAssert.AreEquivalent(expGenres, show.Genres.ToArray());

            Assert.AreEqual(expHomepage, show.Homepage);

            var expLanguages = new[] { "es", "en", "de" };

            CollectionAssert.AreEquivalent(expLanguages, show.Languages.ToArray());

            Assert.AreEqual(expName, show.Name);

            Network[] expNetworks =
            {
                new Network(49, "HBO")
            };

            CollectionAssert.AreEquivalent(expNetworks, show.Networks.ToArray());

            var expCountryCodes = new[] { "US" };

            CollectionAssert.AreEquivalent(expCountryCodes, show.OriginCountry.ToArray());

            Assert.AreEqual(expOriginalLanguage, show.OriginalLanguage);

            ApiResponseUtil.AssertImagePath(show.BackdropPath);
            ApiResponseUtil.AssertImagePath(show.PosterPath);

            ProductionCompanyInfo[] expProductionCompanies =
            {
                new ProductionCompanyInfo(3268,  "Home Box Office (HBO)"),
                new ProductionCompanyInfo(5820,  "Generator Entertainment"),
                new ProductionCompanyInfo(12525, "Television 360"),
                new ProductionCompanyInfo(12526, "Bighead Littlehead"),
                new ProductionCompanyInfo(76043, "Revolution Sun Studios")
            };
            CollectionAssert.AreEquivalent(expProductionCompanies, show.ProductionCompanies.ToArray());

            Keyword[] expKeywords =
            {
                new Keyword(6091,   "war"),
                new Keyword(818,    "based on novel"),
                new Keyword(4152,   "kingdom"),
                new Keyword(12554,  "dragon"),
                new Keyword(13084,  "king"),
                new Keyword(34038,  "intrigue"),
                new Keyword(170362, "fantasy world"),
            };
            CollectionAssert.AreEquivalent(expKeywords, show.Keywords.ToArray());

            Assert.IsNotNull(show.Backdrops);
            Assert.IsNotNull(show.Posters);

            Assert.AreNotEqual(0, show.Backdrops.Count);
            Assert.AreNotEqual(0, show.Posters);

            var backdrop = show.Backdrops[0];

            Assert.AreNotEqual(0, backdrop.AspectRatio);
            ApiResponseUtil.AssertImagePath(backdrop.FilePath);
            Assert.AreNotEqual(0, backdrop.Height);
            Assert.AreNotEqual(0, backdrop.Width);
        }