示例#1
0
        public async Task Test_TraktPeopleModule_GetPerson_With_ExtendedInfo()
        {
            TraktClient client = TestUtility.GetMockClient($"{GET_PERSON_URI}?extended={EXTENDED_INFO}", PERSON_FULL_JSON);
            TraktResponse <ITraktPerson> response = await client.People.GetPersonAsync(PERSON_ID, EXTENDED_INFO);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull();

            ITraktPerson responseValue = response.Value;

            responseValue.Name.Should().Be("Bryan Cranston");
            responseValue.Ids.Should().NotBeNull();
            responseValue.Ids.Trakt.Should().Be(297737U);
            responseValue.Ids.Slug.Should().Be("bryan-cranston");
            responseValue.Ids.Imdb.Should().Be("nm0186505");
            responseValue.Ids.Tmdb.Should().Be(17419U);
            responseValue.Ids.TvRage.Should().Be(1797U);
            responseValue.Biography.Should().Be("Bryan Lee Cranston (born March 7, 1956) is an American actor, voice actor, writer and director.He is perhaps best known for his roles as Hal, the father in the Fox situation comedy \"Malcolm in the Middle\", and as Walter White in the AMC drama series Breaking Bad, for which he has won three consecutive Outstanding Lead Actor in a Drama Series Emmy Awards. Other notable roles include Dr. Tim Whatley on Seinfeld, Doug Heffernan's neighbor in The King of Queens, Astronaut Buzz Aldrin in From the Earth to the Moon, and Ted Mosby's boss on How I Met Your Mother. Description above from the Wikipedia article Bryan Cranston, licensed under CC-BY-SA, full list of contributors on Wikipedia.");
            responseValue.Birthday.Should().Be(DateTime.Parse("1956-03-07T00:00:00Z").ToUniversalTime());
            responseValue.Death.Should().Be(DateTime.Parse("2016-04-06T00:00:00Z").ToUniversalTime());
            responseValue.Age.Should().Be(60);
            responseValue.Birthplace.Should().Be("San Fernando Valley, California, USA");
            responseValue.Homepage.Should().Be("http://www.bryancranston.com/");
        }
示例#2
0
        public void Test_TraktPost_UserCustomListItemsPostBuilder_WithPerson()
        {
            ITraktPerson episode = new TraktPerson
            {
                Ids = new TraktPersonIds
                {
                    Trakt  = 1,
                    Imdb   = "ttpersonname",
                    Tmdb   = 1,
                    TvRage = 1
                }
            };

            ITraktUserCustomListItemsPost userCustomListItemsPost = TraktPost.NewUserCustomListItemsPost()
                                                                    .WithPerson(episode)
                                                                    .Build();

            userCustomListItemsPost.Should().NotBeNull();
            userCustomListItemsPost.People.Should().NotBeNull().And.HaveCount(1);

            ITraktPerson postPerson = userCustomListItemsPost.People.ToArray()[0];

            postPerson.Ids.Should().NotBeNull();
            postPerson.Ids.Trakt.Should().Be(1U);
            postPerson.Ids.Imdb.Should().Be("ttpersonname");
            postPerson.Ids.Tmdb.Should().Be(1U);
            postPerson.Ids.TvRage.Should().Be(1U);

            userCustomListItemsPost.Movies.Should().NotBeNull().And.BeEmpty();
            userCustomListItemsPost.Shows.Should().NotBeNull().And.BeEmpty();
        }
示例#3
0
        /// <summary>Adds a <see cref="ITraktPerson" />, which will be added to the user custom list items post.</summary>
        /// <param name="person">The Trakt person, which will be added.</param>
        /// <returns>The current <see cref="TraktUserCustomListItemsPostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given person is null.
        /// Thrown, if the given person ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown, if the given person has no valid ids set.
        /// Thrown, if the given person has no name.
        /// </exception>
        public TraktUserCustomListItemsPostBuilder AddPerson(ITraktPerson person)
        {
            if (person == null)
            {
                throw new ArgumentNullException(nameof(person));
            }

            if (person.Ids == null)
            {
                throw new ArgumentNullException(nameof(person.Ids));
            }

            if (!person.Ids.HasAnyId)
            {
                throw new ArgumentException("no person ids set or valid", nameof(person.Ids));
            }

            if (string.IsNullOrEmpty(person.Name))
            {
                throw new ArgumentException("person name not valid", nameof(person.Name));
            }

            EnsurePeopleListExists();

            var existingPerson = _listItemsPost.People.FirstOrDefault(p => p == person);

            if (existingPerson != null)
            {
                return(this);
            }

            (_listItemsPost.People as List <ITraktPerson>)?.Add(person);

            return(this);
        }
示例#4
0
 private ITraktPerson CreateUserCustomListItemsPostPerson(ITraktPerson person)
 {
     return(new TraktPerson
     {
         Ids = person.Ids
     });
 }
示例#5
0
        public ITraktUserCustomListItemsPostBuilder WithPerson(ITraktPerson person)
        {
            if (person == null)
            {
                throw new ArgumentNullException(nameof(person));
            }

            _persons.Add(person);
            return(this);
        }
示例#6
0
        public async Task Test_TraktPeopleModule_GetPerson()
        {
            TraktClient client = TestUtility.GetMockClient(GET_PERSON_URI, PERSON_MINIMAL_JSON);
            TraktResponse <ITraktPerson> response = await client.People.GetPersonAsync(PERSON_ID);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull();

            ITraktPerson responseValue = response.Value;

            responseValue.Name.Should().Be("Bryan Cranston");
            responseValue.Ids.Should().NotBeNull();
            responseValue.Ids.Trakt.Should().Be(297737U);
            responseValue.Ids.Slug.Should().Be("bryan-cranston");
            responseValue.Ids.Imdb.Should().Be("nm0186505");
            responseValue.Ids.Tmdb.Should().Be(17419U);
            responseValue.Ids.TvRage.Should().Be(1797U);
        }