Exemple #1
0
        // happy path
        public async Task WhenCalledOnActor_ReturnsPersonsDetails()
        {
            GetPersonsDetailsResult response = await _client.GetPersonsDetails(personId : _actor, language : null, retryCount : 0, delayMilliseconds : 1000);

            Assert.True(response.HttpStatusCode == System.Net.HttpStatusCode.OK);

            PersonsDetailsModel personsDetails = JsonConvert.DeserializeObject <PersonsDetailsModel>(response.Json);

            PrintPersonsDetails(personsDetails);

            Assert.Contains("Daniel Day-Lewis", personsDetails.Name, System.StringComparison.InvariantCultureIgnoreCase);
        }
        public async Task <TryGetPersonsDetailsResponse> TryGetPersonsDetails(int personId, string language = null, int retryCount = 0, int delayMilliseconds = 1000, bool fromCache = true)
        {
            var response = await _cachedSearchClient.GetPersonsDetails(personId, language, retryCount, delayMilliseconds, fromCache);

            PersonsDetailsModel personsDetails = null;

            if (response.HttpStatusCode.IsSuccessCode())
            {
                personsDetails = JsonConvert.DeserializeObject <PersonsDetailsModel>(response.Json);
            }

            return(new TryGetPersonsDetailsResponse(response.HttpStatusCode, personsDetails));
        }
        public string Compose(PersonsDetailsModel person)
        {
            if (_settings.InfoLinkTargetHomePage == InformationLinkTargetHomePage.IMDb)
            {
                if (!string.IsNullOrEmpty(person.ImdbId))
                {
                    return(IMDb_Person_Base + person.ImdbId);
                }
            }
            else if (_settings.InfoLinkTargetHomePage == InformationLinkTargetHomePage.TMDb)
            {
                return(TMDb_Person_Base + person.Id);
            }
            else if (_settings.InfoLinkTargetHomePage == InformationLinkTargetHomePage.Invalid)
            {
                return(null);
            }

            return(null);
        }
Exemple #4
0
        // NO, server currently does not return localized biographies
        // TmdbNetworkClient call should be initiated without language option set

        //[Fact]
        //// happy path
        //public async Task WhenCalledWithLanguageOption_ReturnsResultsInLanguage()
        //{
        //    string language = "de";

        //    GetPersonsDetailsResult response = await _client.GetPersonsDetails(personId: _actor2, language: language, retryCount: 0, delayMilliseconds: 1000);
        //    Assert.True(response.HttpStatusCode == System.Net.HttpStatusCode.OK);

        //    GetPersonsDetailsModel personsDetails = JsonConvert.DeserializeObject<GetPersonsDetailsModel>(response.Json);
        //    PrintPersonsDetails(personsDetails);
        //}

        private void PrintPersonsDetails(PersonsDetailsModel person)
        {
            _output.WriteLine($"Id: {person.Id}");
            _output.WriteLine($"Name: {person.Name}");
            _output.WriteLine($"Biography: {person.Biography}");
            _output.WriteLine($"Known for: {person.KnownFor}");
            _output.WriteLine($"Birthday: {person.Birthday}");
            _output.WriteLine($"Place of birth: {person.PlaceOfBirth}");
            _output.WriteLine($"Death day: {person.DeathDay ?? ""}");

            _output.WriteLine($"Sex: {person.Sex}");
            _output.WriteLine($"Popularity: {person.Popularity}");
            _output.WriteLine($"Profile: {person.ProfilePath}");
            _output.WriteLine($"IMDB id: {person.ImdbId}");
            _output.WriteLine($"Adult: {person.Adult}");

            _output.WriteLine($"Nicknames");
            foreach (var nickName in person.AlsoKnownAs)
            {
                _output.WriteLine(nickName);
            }
        }
 public TryGetPersonsDetailsResponse(HttpStatusCode statusCode, PersonsDetailsModel personsDetails)
 {
     HttpStatusCode      = statusCode;
     PersonsDetailsModel = personsDetails;
 }
 /// <summary>
 /// Sets the FilePath property to the full url of the profile image hosted on the content server for the ImageModel.
 /// The image url is composed from PersonDetailModel's relative image path, and the base path and settings extracted from TmdbConfigurationModel
 /// </summary>
 /// <param name="profileGalleryImage">image which needs its FilePath property set to the complete image file url</param>
 /// <param name="personModel">object from which the relative file url is copied</param>
 /// <param name="profileImageSize">Quality selector 0: lowest, 1: high, 2 very high, 3: original. Uses TmdbConfigurationModel</param>
 public void SetProfileGalleryPictureImageSrc(ImageModel profileGalleryImage, PersonsDetailsModel personModel, int profileImageSize = 1) =>
 profileGalleryImage.FilePath = ImageBaseUrl + _tmdbConfiguration.Images.ProfileSizes[profileImageSize] + personModel.ProfilePath;