public void Test_PostResponseNotFoundShowArrayJsonReader_ReadArray_From_Json_String_Null()
        {
            var jsonReader = new ArrayJsonReader <ITraktPostResponseNotFoundShow>();
            Func <Task <IEnumerable <ITraktPostResponseNotFoundShow> > > notFoundShows = () => jsonReader.ReadArrayAsync(default(string));

            notFoundShows.Should().Throw <ArgumentNullException>();
        }
 public async Task Test_EpisodeCollectionProgressArrayJsonReader_ReadArray_From_JsonReader_Null()
 {
     var traktJsonReader = new ArrayJsonReader <ITraktEpisodeCollectionProgress>();
     Func <Task <IEnumerable <ITraktEpisodeCollectionProgress> > > traktEpisodeCollectionProgress = () => traktJsonReader.ReadArrayAsync(default(JsonTextReader));
     await traktEpisodeCollectionProgress.Should().ThrowAsync <ArgumentNullException>();
 }
        public void Test_WatchedShowSeasonArrayJsonReader_ReadArray_From_Stream_Null()
        {
            var jsonReader = new ArrayJsonReader <ITraktWatchedShowSeason>();
            Func <Task <IEnumerable <ITraktWatchedShowSeason> > > traktSeasonWatchedProgress = () => jsonReader.ReadArrayAsync(default(Stream));

            traktSeasonWatchedProgress.Should().Throw <ArgumentNullException>();
        }
 public async Task Test_WatchedShowSeasonArrayJsonReader_ReadArray_From_JsonReader_Null()
 {
     var traktJsonReader = new ArrayJsonReader <ITraktWatchedShowSeason>();
     Func <Task <IEnumerable <ITraktWatchedShowSeason> > > traktSeasonWatchedProgress = () => traktJsonReader.ReadArrayAsync(default(JsonTextReader));
     await traktSeasonWatchedProgress.Should().ThrowAsync <ArgumentNullException>();
 }
Beispiel #5
0
 public async Task Test_CalendarShowArrayJsonReader_ReadArray_From_JsonReader_Null()
 {
     var traktJsonReader = new ArrayJsonReader <ITraktCalendarShow>();
     Func <Task <IEnumerable <ITraktCalendarShow> > > traktCalendarShows = () => traktJsonReader.ReadArrayAsync(default(JsonTextReader));
     await traktCalendarShows.Should().ThrowAsync <ArgumentNullException>();
 }
Beispiel #6
0
        public async Task Test_UserCustomListsReorderPostArrayJsonReader_ReadArray_From_JsonReader_Not_Valid_3()
        {
            var traktJsonReader = new ArrayJsonReader <ITraktUserCustomListsReorderPost>();

            using (var reader = new StringReader(JSON_NOT_VALID_3))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    IEnumerable <ITraktUserCustomListsReorderPost> traktUserCustomListsReorderPosts = await traktJsonReader.ReadArrayAsync(jsonReader);

                    traktUserCustomListsReorderPosts.Should().NotBeNull();
                    ITraktUserCustomListsReorderPost[] userCustomListsReorderPosts = traktUserCustomListsReorderPosts.ToArray();

                    userCustomListsReorderPosts[0].Should().NotBeNull();
                    userCustomListsReorderPosts[0].Rank.Should().BeNull();

                    userCustomListsReorderPosts[1].Should().NotBeNull();
                    userCustomListsReorderPosts[1].Rank.Should().BeNull();
                }
        }
Beispiel #7
0
        public async Task Test_UserCustomListsReorderPostArrayJsonReader_ReadArray_From_JsonReader_Empty()
        {
            var traktJsonReader = new ArrayJsonReader <ITraktUserCustomListsReorderPost>();

            using (var reader = new StringReader(string.Empty))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    IEnumerable <ITraktUserCustomListsReorderPost> traktUserCustomListsReorderPosts = await traktJsonReader.ReadArrayAsync(jsonReader);

                    traktUserCustomListsReorderPosts.Should().BeNull();
                }
        }
        public async Task Test_SeasonWatchedProgressArrayJsonReader_ReadArray_From_Stream_Not_Valid_3()
        {
            var traktJsonReader = new ArrayJsonReader <ITraktSeasonWatchedProgress>();

            using (var stream = JSON_NOT_VALID_3.ToStream())
            {
                var traktSeasonWatchedProgresses = await traktJsonReader.ReadArrayAsync(stream);

                traktSeasonWatchedProgresses.Should().NotBeNull().And.NotBeEmpty().And.HaveCount(3);

                var watchedProgresses = traktSeasonWatchedProgresses.ToArray();

                watchedProgresses[0].Number.Should().Be(1);
                watchedProgresses[0].Aired.Should().Be(3);
                watchedProgresses[0].Completed.Should().Be(2);
                watchedProgresses[0].Episodes.Should().NotBeNull().And.HaveCount(2);

                var episodesWatchedProgress = watchedProgresses[0].Episodes.ToArray();

                episodesWatchedProgress[0].Should().NotBeNull();
                episodesWatchedProgress[0].Number.Should().Be(1);
                episodesWatchedProgress[0].Completed.Should().BeTrue();
                episodesWatchedProgress[0].LastWatchedAt.Should().Be(DateTime.Parse("2011-04-18T01:00:00.000Z").ToUniversalTime());

                episodesWatchedProgress[1].Should().NotBeNull();
                episodesWatchedProgress[1].Number.Should().Be(2);
                episodesWatchedProgress[1].Completed.Should().BeTrue();
                episodesWatchedProgress[1].LastWatchedAt.Should().Be(DateTime.Parse("2011-04-19T02:00:00.000Z").ToUniversalTime());

                // -----------------------------------------------

                watchedProgresses[1].Number.Should().Be(2);
                watchedProgresses[1].Aired.Should().Be(3);
                watchedProgresses[1].Completed.Should().Be(2);
                watchedProgresses[1].Episodes.Should().NotBeNull().And.HaveCount(2);

                episodesWatchedProgress = watchedProgresses[1].Episodes.ToArray();

                episodesWatchedProgress[0].Should().NotBeNull();
                episodesWatchedProgress[0].Number.Should().Be(1);
                episodesWatchedProgress[0].Completed.Should().BeTrue();
                episodesWatchedProgress[0].LastWatchedAt.Should().Be(DateTime.Parse("2011-04-18T01:00:00.000Z").ToUniversalTime());

                episodesWatchedProgress[1].Should().NotBeNull();
                episodesWatchedProgress[1].Number.Should().Be(2);
                episodesWatchedProgress[1].Completed.Should().BeTrue();
                episodesWatchedProgress[1].LastWatchedAt.Should().Be(DateTime.Parse("2011-04-19T02:00:00.000Z").ToUniversalTime());

                // -----------------------------------------------

                watchedProgresses[2].Number.Should().Be(3);
                watchedProgresses[2].Aired.Should().Be(3);
                watchedProgresses[2].Completed.Should().BeNull();
                watchedProgresses[2].Episodes.Should().NotBeNull().And.HaveCount(2);

                episodesWatchedProgress = watchedProgresses[2].Episodes.ToArray();

                episodesWatchedProgress[0].Should().NotBeNull();
                episodesWatchedProgress[0].Number.Should().Be(1);
                episodesWatchedProgress[0].Completed.Should().BeTrue();
                episodesWatchedProgress[0].LastWatchedAt.Should().Be(DateTime.Parse("2011-04-18T01:00:00.000Z").ToUniversalTime());

                episodesWatchedProgress[1].Should().NotBeNull();
                episodesWatchedProgress[1].Number.Should().Be(2);
                episodesWatchedProgress[1].Completed.Should().BeTrue();
                episodesWatchedProgress[1].LastWatchedAt.Should().Be(DateTime.Parse("2011-04-19T02:00:00.000Z").ToUniversalTime());
            }
        }
 public async Task Test_SeasonWatchedProgressArrayJsonReader_ReadArray_From_Stream_Null()
 {
     var traktJsonReader = new ArrayJsonReader <ITraktSeasonWatchedProgress>();
     Func <Task <IEnumerable <ITraktSeasonWatchedProgress> > > traktSeasonWatchedProgresses = () => traktJsonReader.ReadArrayAsync(default(Stream));
     await traktSeasonWatchedProgresses.Should().ThrowAsync <ArgumentNullException>();
 }
Beispiel #10
0
        public async Task Test_CrewArrayJsonReader_ReadArray_From_Stream_Not_Valid_3()
        {
            var jsonReader = new ArrayJsonReader <ITraktCrew>();

            using (var stream = JSON_NOT_VALID_3.ToStream())
            {
                IEnumerable <ITraktCrew> traktCrews = await jsonReader.ReadArrayAsync(stream);

                traktCrews.Should().NotBeNull();
                ITraktCrew[] crews = traktCrews.ToArray();

                crews[0].Production.Should().NotBeNull().And.HaveCount(1);
                ITraktCrewMember[] productionCrew = crews[0].Production.ToArray();

                productionCrew[0].Should().NotBeNull();
                productionCrew[0].Jobs.Should().BeNull();
                productionCrew[0].Person.Should().NotBeNull();
                productionCrew[0].Person.Name.Should().Be("Bryan Cranston");
                productionCrew[0].Person.Ids.Should().NotBeNull();
                productionCrew[0].Person.Ids.Trakt.Should().Be(297737U);
                productionCrew[0].Person.Ids.Slug.Should().Be("bryan-cranston");
                productionCrew[0].Person.Ids.Imdb.Should().Be("nm0186505");
                productionCrew[0].Person.Ids.Tmdb.Should().Be(17419U);
                productionCrew[0].Person.Ids.TvRage.Should().Be(1797U);

                crews[0].Art.Should().BeNull();
                crews[0].Crew.Should().BeNull();
                crews[0].CostumeAndMakeup.Should().BeNull();
                crews[0].Directing.Should().BeNull();
                crews[0].Writing.Should().BeNull();
                crews[0].Sound.Should().BeNull();
                crews[0].Camera.Should().BeNull();
                crews[0].Lighting.Should().BeNull();
                crews[0].VisualEffects.Should().BeNull();
                crews[0].Editing.Should().BeNull();

                crews[1].Production.Should().NotBeNull().And.HaveCount(1);
                productionCrew = crews[1].Production.ToArray();

                productionCrew[0].Should().NotBeNull();
                productionCrew[0].Jobs.Should().BeNull();
                productionCrew[0].Person.Should().NotBeNull();
                productionCrew[0].Person.Name.Should().Be("Bryan Cranston");
                productionCrew[0].Person.Ids.Should().NotBeNull();
                productionCrew[0].Person.Ids.Trakt.Should().Be(297737U);
                productionCrew[0].Person.Ids.Slug.Should().Be("bryan-cranston");
                productionCrew[0].Person.Ids.Imdb.Should().Be("nm0186505");
                productionCrew[0].Person.Ids.Tmdb.Should().Be(17419U);
                productionCrew[0].Person.Ids.TvRage.Should().Be(1797U);

                crews[1].Art.Should().BeNull();
                crews[1].Crew.Should().BeNull();
                crews[1].CostumeAndMakeup.Should().BeNull();
                crews[1].Directing.Should().BeNull();
                crews[1].Writing.Should().BeNull();
                crews[1].Sound.Should().BeNull();
                crews[1].Camera.Should().BeNull();
                crews[1].Lighting.Should().BeNull();
                crews[1].VisualEffects.Should().BeNull();
                crews[1].Editing.Should().BeNull();
            }
        }
Beispiel #11
0
 public async Task Test_CrewArrayJsonReader_ReadArray_From_Stream_Null()
 {
     var jsonReader = new ArrayJsonReader <ITraktCrew>();
     Func <Task <IEnumerable <ITraktCrew> > > traktCrews = () => jsonReader.ReadArrayAsync(default(Stream));
     await traktCrews.Should().ThrowAsync <ArgumentNullException>();
 }
Beispiel #12
0
        public void Test_PostResponseNotFoundMovieArrayJsonReader_ReadArray_From_Stream_Null()
        {
            var jsonReader = new ArrayJsonReader <ITraktPostResponseNotFoundMovie>();
            Func <Task <IEnumerable <ITraktPostResponseNotFoundMovie> > > notFoundMovies = () => jsonReader.ReadArrayAsync(default(Stream));

            notFoundMovies.Should().Throw <ArgumentNullException>();
        }
        public void Test_CollectionMovieArrayJsonReader_ReadArray_From_Stream_Null()
        {
            var jsonReader = new ArrayJsonReader <ITraktCollectionMovie>();
            Func <Task <IEnumerable <ITraktCollectionMovie> > > traktCollectionMovies = () => jsonReader.ReadArrayAsync(default(Stream));

            traktCollectionMovies.Should().Throw <ArgumentNullException>();
        }
Beispiel #14
0
 public async Task Test_WatchedShowEpisodeArrayJsonReader_ReadArray_From_Json_String_Null()
 {
     var jsonReader = new ArrayJsonReader <ITraktWatchedShowEpisode>();
     Func <Task <IEnumerable <ITraktWatchedShowEpisode> > > traktEpisodeWatchedProgress = () => jsonReader.ReadArrayAsync(default(string));
     await traktEpisodeWatchedProgress.Should().ThrowAsync <ArgumentNullException>();
 }
Beispiel #15
0
        public void Test_PersonMovieCreditsCrewItemArrayJsonReader_ReadObject_From_JsonReader_Null()
        {
            var traktJsonReader = new ArrayJsonReader <ITraktPersonMovieCreditsCrewItem>();
            Func <Task <IEnumerable <ITraktPersonMovieCreditsCrewItem> > > movieCreditsCrewItems = () => traktJsonReader.ReadArrayAsync(default(JsonTextReader));

            movieCreditsCrewItems.Should().Throw <ArgumentNullException>();
        }
        public void Test_CollectionShowEpisodeArrayJsonReader_ReadArray_From_Json_String_Null()
        {
            var jsonReader = new ArrayJsonReader <ITraktCollectionShowEpisode>();
            Func <Task <IEnumerable <ITraktCollectionShowEpisode> > > traktCollectionShowEpisodes = () => jsonReader.ReadArrayAsync(default(string));

            traktCollectionShowEpisodes.Should().Throw <ArgumentNullException>();
        }
        public override async Task <ITraktCollectionShow> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var showObjectReader       = new ShowObjectJsonReader();
                var showSeasonsArrayReader = new ArrayJsonReader <ITraktCollectionShowSeason>();

                ITraktCollectionShow traktCollectionShow = new TraktCollectionShow();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_LAST_COLLECTED_AT:
                    {
                        var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktCollectionShow.LastCollectedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_LAST_UPDATED_AT:
                    {
                        var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktCollectionShow.LastUpdatedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_SHOW:
                        traktCollectionShow.Show = await showObjectReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SEASONS:
                        traktCollectionShow.CollectionSeasons = await showSeasonsArrayReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktCollectionShow);
            }

            return(await Task.FromResult(default(ITraktCollectionShow)));
        }
 public async Task Test_PersonShowCreditsCrewItemArrayJsonReader_ReadObject_From_Json_String_Null()
 {
     var jsonReader = new ArrayJsonReader <ITraktPersonShowCreditsCrewItem>();
     Func <Task <IEnumerable <ITraktPersonShowCreditsCrewItem> > > showCreditsCrewItems = () => jsonReader.ReadArrayAsync(default(string));
     await showCreditsCrewItems.Should().ThrowAsync <ArgumentNullException>();
 }
Beispiel #19
0
 public async Task Test_UserCustomListsReorderPostArrayJsonReader_ReadArray_From_JsonReader_Null()
 {
     var traktJsonReader = new ArrayJsonReader <ITraktUserCustomListsReorderPost>();
     Func <Task <IEnumerable <ITraktUserCustomListsReorderPost> > > traktUserCustomListsReorderPosts = () => traktJsonReader.ReadArrayAsync(default(JsonTextReader));
     await traktUserCustomListsReorderPosts.Should().ThrowAsync <ArgumentNullException>();
 }
Beispiel #20
0
 public async Task Test_PersonMovieCreditsCastItemArrayJsonReader_ReadObject_From_Stream_Null()
 {
     var jsonReader = new ArrayJsonReader <ITraktPersonMovieCreditsCastItem>();
     Func <Task <IEnumerable <ITraktPersonMovieCreditsCastItem> > > movieCreditsCastItems = () => jsonReader.ReadArrayAsync(default(Stream));
     await movieCreditsCastItems.Should().ThrowAsync <ArgumentNullException>();
 }
Beispiel #21
0
        public async Task Test_UserCustomListsReorderPostArrayJsonReader_ReadArray_From_JsonReader_Incomplete_2()
        {
            var traktJsonReader = new ArrayJsonReader <ITraktUserCustomListsReorderPost>();

            using (var reader = new StringReader(JSON_INCOMPLETE_2))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    IEnumerable <ITraktUserCustomListsReorderPost> traktUserCustomListsReorderPosts = await traktJsonReader.ReadArrayAsync(jsonReader);

                    traktUserCustomListsReorderPosts.Should().NotBeNull();
                    ITraktUserCustomListsReorderPost[] userCustomListsReorderPosts = traktUserCustomListsReorderPosts.ToArray();

                    userCustomListsReorderPosts[0].Should().NotBeNull();
                    userCustomListsReorderPosts[0].Rank.Should().BeNull();

                    userCustomListsReorderPosts[1].Should().NotBeNull();
                    userCustomListsReorderPosts[1].Rank.Should().NotBeNull().And.HaveCount(7);
                    userCustomListsReorderPosts[1].Rank.Should().BeEquivalentTo(new List <uint> {
                        823, 224, 88768, 356456, 245, 2, 890
                    });
                }
        }
Beispiel #22
0
 public async Task Test_DeviceArrayJsonReader_ReadObject_From_JsonReader_Null()
 {
     var objectJsonReader = new ArrayJsonReader <ITraktDevice>();
     Func <Task <IEnumerable <ITraktDevice> > > traktDevices = () => objectJsonReader.ReadArrayAsync(default(JsonTextReader));
     await traktDevices.Should().ThrowAsync <ArgumentNullException>();
 }
Beispiel #23
0
        public void Test_PostResponseNotFoundShowArrayJsonReader_ReadArray_From_JsonReader_Null()
        {
            var traktJsonReader = new ArrayJsonReader <ITraktPostResponseNotFoundShow>();
            Func <Task <IEnumerable <ITraktPostResponseNotFoundShow> > > traktShowCollectionProgress = () => traktJsonReader.ReadArrayAsync(default(JsonTextReader));

            traktShowCollectionProgress.Should().Throw <ArgumentNullException>();
        }
 public async Task Test_PostResponseNotFoundPersonArrayJsonReader_ReadArray_From_Stream_Null()
 {
     var jsonReader = new ArrayJsonReader <ITraktPostResponseNotFoundPerson>();
     Func <Task <IEnumerable <ITraktPostResponseNotFoundPerson> > > notFoundPersons = () => jsonReader.ReadArrayAsync(default(Stream));
     await notFoundPersons.Should().ThrowAsync <ArgumentNullException>();
 }
        public void Test_HistoryItemArrayJsonReader_ReadArray_From_Stream_Null()
        {
            var traktJsonReader = new ArrayJsonReader <ITraktHistoryItem>();
            Func <Task <IEnumerable <ITraktHistoryItem> > > traktHistoryItems = () => traktJsonReader.ReadArrayAsync(default(Stream));

            traktHistoryItems.Should().Throw <ArgumentNullException>();
        }
        public async Task Test_SeasonArrayJsonReader_ReadArray_From_JsonReader_Full_Complete()
        {
            var traktJsonReader = new ArrayJsonReader <ITraktSeason>();

            using (var reader = new StringReader(FULL_JSON_COMPLETE))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    var traktSeasons = await traktJsonReader.ReadArrayAsync(jsonReader);

                    traktSeasons.Should().NotBeNull().And.NotBeEmpty().And.HaveCount(2);

                    var seasons = traktSeasons.ToArray();

                    seasons[0].Should().NotBeNull();
                    seasons[0].Number.Should().Be(1);
                    seasons[0].Ids.Should().NotBeNull();
                    seasons[0].Ids.Trakt.Should().Be(61430U);
                    seasons[0].Ids.Tvdb.Should().Be(279121U);
                    seasons[0].Ids.Tmdb.Should().Be(60523U);
                    seasons[0].Ids.TvRage.Should().Be(36939U);
                    seasons[0].Rating.Should().Be(8.57053f);
                    seasons[0].Votes.Should().Be(794);
                    seasons[0].TotalEpisodesCount.Should().Be(10);
                    seasons[0].AiredEpisodesCount.Should().Be(10);
                    seasons[0].Overview.Should().Be("Trouble is brewing in the Seven Kingdoms of Westeros. For the driven inhabitants of this visionary world, control of Westeros' Iron Throne holds the lure of great power. But in a land where the seasons can last a lifetime, winter is coming...and beyond the Great Wall that protects them, an ancient evil has returned. In Season One, the story centers on three primary areas: the Stark and the Lannister families, whose designs on controlling the throne threaten a tenuous peace; the dragon princess Daenerys, heir to the former dynasty, who waits just over the Narrow Sea with her malevolent brother Viserys; and the Great Wall--a massive barrier of ice where a forgotten danger is stirring.");
                    seasons[0].FirstAired.Should().Be(DateTime.Parse("2011-04-18T01:00:00.000Z").ToUniversalTime());
                    seasons[0].Network.Should().Be("The CW");
                    seasons[0].Episodes.Should().NotBeNull().And.HaveCount(2);

                    var episodes = seasons[0].Episodes.ToArray();

                    episodes[0].Should().NotBeNull();
                    episodes[0].SeasonNumber.Should().Be(1);
                    episodes[0].Number.Should().Be(1);
                    episodes[0].Title.Should().Be("Winter Is Coming");
                    episodes[0].Ids.Should().NotBeNull();
                    episodes[0].Ids.Trakt.Should().Be(73640U);
                    episodes[0].Ids.Tvdb.Should().Be(3254641U);
                    episodes[0].Ids.Imdb.Should().Be("tt1480055");
                    episodes[0].Ids.Tmdb.Should().Be(63056U);
                    episodes[0].Ids.TvRage.Should().Be(1065008299U);
                    episodes[0].NumberAbsolute.Should().NotHaveValue();
                    episodes[0].Overview.Should().BeNullOrEmpty();
                    episodes[0].Runtime.Should().NotHaveValue();
                    episodes[0].Rating.Should().NotHaveValue();
                    episodes[0].Votes.Should().NotHaveValue();
                    episodes[0].FirstAired.Should().NotHaveValue();
                    episodes[0].UpdatedAt.Should().NotHaveValue();
                    episodes[0].AvailableTranslationLanguageCodes.Should().BeNull();
                    episodes[0].Translations.Should().BeNull();

                    episodes[1].Should().NotBeNull();
                    episodes[1].SeasonNumber.Should().Be(1);
                    episodes[1].Number.Should().Be(2);
                    episodes[1].Title.Should().Be("The Kingsroad");
                    episodes[1].Ids.Should().NotBeNull();
                    episodes[1].Ids.Trakt.Should().Be(74138U);
                    episodes[1].Ids.Tvdb.Should().Be(3436411U);
                    episodes[1].Ids.Imdb.Should().Be("tt1668746");
                    episodes[1].Ids.Tmdb.Should().Be(63141U);
                    episodes[1].Ids.TvRage.Should().Be(1325718577U);
                    episodes[1].NumberAbsolute.Should().NotHaveValue();
                    episodes[1].Overview.Should().BeNullOrEmpty();
                    episodes[1].Runtime.Should().NotHaveValue();
                    episodes[1].Rating.Should().NotHaveValue();
                    episodes[1].Votes.Should().NotHaveValue();
                    episodes[1].FirstAired.Should().NotHaveValue();
                    episodes[1].UpdatedAt.Should().NotHaveValue();
                    episodes[1].AvailableTranslationLanguageCodes.Should().BeNull();
                    episodes[1].Translations.Should().BeNull();

                    // ------------------------------------------------------------

                    seasons[1].Should().NotBeNull();
                    seasons[1].Number.Should().Be(2);
                    seasons[1].Ids.Should().NotBeNull();
                    seasons[1].Ids.Trakt.Should().Be(3964U);
                    seasons[1].Ids.Tvdb.Should().Be(473271U);
                    seasons[1].Ids.Tmdb.Should().Be(3625U);
                    seasons[1].Ids.TvRage.Should().Be(36940U);
                    seasons[1].Rating.Should().Be(9.10629f);
                    seasons[1].Votes.Should().Be(1590);
                    seasons[1].TotalEpisodesCount.Should().Be(10);
                    seasons[1].AiredEpisodesCount.Should().Be(10);
                    seasons[1].Overview.Should().Be("The cold winds of winter are rising in Westeros...war is coming...and five kings continue their savage quest for control of the all-powerful Iron Throne. With winter fast approaching, the coveted Iron Throne is occupied by the cruel Joffrey, counseled by his conniving mother Cersei and uncle Tyrion. But the Lannister hold on the Throne is under assault on many fronts. Meanwhile, a new leader is rising among the wildings outside the Great Wall, adding new perils for Jon Snow and the order of the Night's Watch.");
                    seasons[1].FirstAired.Should().Be(DateTime.Parse("2012-04-02T01:00:00.000Z").ToUniversalTime());
                    seasons[1].Network.Should().Be("The CW");
                    seasons[1].Episodes.Should().NotBeNull().And.HaveCount(2);

                    episodes = seasons[1].Episodes.ToArray();

                    episodes[0].Should().NotBeNull();
                    episodes[0].SeasonNumber.Should().Be(2);
                    episodes[0].Number.Should().Be(1);
                    episodes[0].Title.Should().Be("The North Remembers");
                    episodes[0].Ids.Should().NotBeNull();
                    episodes[0].Ids.Trakt.Should().Be(73650U);
                    episodes[0].Ids.Tvdb.Should().Be(4161693U);
                    episodes[0].Ids.Imdb.Should().Be("tt1971833");
                    episodes[0].Ids.Tmdb.Should().Be(63066U);
                    episodes[0].Ids.TvRage.Should().Be(1065074755U);
                    episodes[0].NumberAbsolute.Should().NotHaveValue();
                    episodes[0].Overview.Should().BeNullOrEmpty();
                    episodes[0].Runtime.Should().NotHaveValue();
                    episodes[0].Rating.Should().NotHaveValue();
                    episodes[0].Votes.Should().NotHaveValue();
                    episodes[0].FirstAired.Should().NotHaveValue();
                    episodes[0].UpdatedAt.Should().NotHaveValue();
                    episodes[0].AvailableTranslationLanguageCodes.Should().BeNull();
                    episodes[0].Translations.Should().BeNull();

                    episodes[1].Should().NotBeNull();
                    episodes[1].SeasonNumber.Should().Be(2);
                    episodes[1].Number.Should().Be(2);
                    episodes[1].Title.Should().Be("The Night Lands");
                    episodes[1].Ids.Should().NotBeNull();
                    episodes[1].Ids.Trakt.Should().Be(73651U);
                    episodes[1].Ids.Tvdb.Should().Be(4245771U);
                    episodes[1].Ids.Imdb.Should().Be("tt2069318");
                    episodes[1].Ids.Tmdb.Should().Be(974430U);
                    episodes[1].Ids.TvRage.Should().Be(1065150289U);
                    episodes[1].NumberAbsolute.Should().NotHaveValue();
                    episodes[1].Overview.Should().BeNullOrEmpty();
                    episodes[1].Runtime.Should().NotHaveValue();
                    episodes[1].Rating.Should().NotHaveValue();
                    episodes[1].Votes.Should().NotHaveValue();
                    episodes[1].FirstAired.Should().NotHaveValue();
                    episodes[1].UpdatedAt.Should().NotHaveValue();
                    episodes[1].AvailableTranslationLanguageCodes.Should().BeNull();
                    episodes[1].Translations.Should().BeNull();
                }
        }
Beispiel #27
0
 public async Task Test_StatisticsArrayJsonReader_ReadArray_From_Json_String_Null()
 {
     var jsonReader = new ArrayJsonReader <ITraktStatistics>();
     Func <Task <IEnumerable <ITraktStatistics> > > traktStatisticss = () => jsonReader.ReadArrayAsync(default(string));
     await traktStatisticss.Should().ThrowAsync <ArgumentNullException>();
 }
Beispiel #28
0
        public async Task Test_HistoryItemArrayJsonReader_Movie_Read_Array_From_Json_String_Incomplete_1()
        {
            var jsonReader = new ArrayJsonReader <ITraktHistoryItem>();

            var traktHistoryItems = await jsonReader.ReadArrayAsync(TYPE_MOVIE_JSON_INCOMPLETE_1);

            traktHistoryItems.Should().NotBeNull().And.NotBeEmpty().And.HaveCount(2);

            var historyItems = traktHistoryItems.ToArray();

            historyItems[0].Should().NotBeNull();
            historyItems[0].Id.Should().Be(1982346UL);
            historyItems[0].WatchedAt.Should().Be(DateTime.Parse("2014-03-31T09:28:53.000Z").ToUniversalTime());
            historyItems[0].Action.Should().Be(TraktHistoryActionType.Scrobble);
            historyItems[0].Type.Should().Be(TraktSyncItemType.Movie);
            historyItems[0].Movie.Should().NotBeNull();
            historyItems[0].Movie.Title.Should().Be("Star Wars: The Force Awakens");
            historyItems[0].Movie.Year.Should().Be(2015);
            historyItems[0].Movie.Ids.Should().NotBeNull();
            historyItems[0].Movie.Ids.Trakt.Should().Be(94024U);
            historyItems[0].Movie.Ids.Slug.Should().Be("star-wars-the-force-awakens-2015");
            historyItems[0].Movie.Ids.Imdb.Should().Be("tt2488496");
            historyItems[0].Movie.Ids.Tmdb.Should().Be(140607U);
            historyItems[0].Movie.Tagline.Should().BeNullOrEmpty();
            historyItems[0].Movie.Overview.Should().BeNullOrEmpty();
            historyItems[0].Movie.Released.Should().NotHaveValue();
            historyItems[0].Movie.Runtime.Should().NotHaveValue();
            historyItems[0].Movie.UpdatedAt.Should().NotHaveValue();
            historyItems[0].Movie.Trailer.Should().BeNullOrEmpty();
            historyItems[0].Movie.Homepage.Should().BeNullOrEmpty();
            historyItems[0].Movie.Rating.Should().NotHaveValue();
            historyItems[0].Movie.Votes.Should().NotHaveValue();
            historyItems[0].Movie.LanguageCode.Should().BeNullOrEmpty();
            historyItems[0].Movie.AvailableTranslationLanguageCodes.Should().BeNull();
            historyItems[0].Movie.Genres.Should().BeNull();
            historyItems[0].Movie.Certification.Should().BeNullOrEmpty();
            historyItems[0].Show.Should().BeNull();
            historyItems[0].Season.Should().BeNull();
            historyItems[0].Episode.Should().BeNull();

            historyItems[1].Should().NotBeNull();
            historyItems[1].Id.Should().Be(0);
            historyItems[1].WatchedAt.Should().Be(DateTime.Parse("2014-03-31T09:28:53.000Z").ToUniversalTime());
            historyItems[1].Action.Should().Be(TraktHistoryActionType.Scrobble);
            historyItems[1].Type.Should().Be(TraktSyncItemType.Movie);
            historyItems[1].Movie.Should().NotBeNull();
            historyItems[1].Movie.Title.Should().Be("Star Wars: The Force Awakens");
            historyItems[1].Movie.Year.Should().Be(2015);
            historyItems[1].Movie.Ids.Should().NotBeNull();
            historyItems[1].Movie.Ids.Trakt.Should().Be(94024U);
            historyItems[1].Movie.Ids.Slug.Should().Be("star-wars-the-force-awakens-2015");
            historyItems[1].Movie.Ids.Imdb.Should().Be("tt2488496");
            historyItems[1].Movie.Ids.Tmdb.Should().Be(140607U);
            historyItems[1].Movie.Tagline.Should().BeNullOrEmpty();
            historyItems[1].Movie.Overview.Should().BeNullOrEmpty();
            historyItems[1].Movie.Released.Should().NotHaveValue();
            historyItems[1].Movie.Runtime.Should().NotHaveValue();
            historyItems[1].Movie.UpdatedAt.Should().NotHaveValue();
            historyItems[1].Movie.Trailer.Should().BeNullOrEmpty();
            historyItems[1].Movie.Homepage.Should().BeNullOrEmpty();
            historyItems[1].Movie.Rating.Should().NotHaveValue();
            historyItems[1].Movie.Votes.Should().NotHaveValue();
            historyItems[1].Movie.LanguageCode.Should().BeNullOrEmpty();
            historyItems[1].Movie.AvailableTranslationLanguageCodes.Should().BeNull();
            historyItems[1].Movie.Genres.Should().BeNull();
            historyItems[1].Movie.Certification.Should().BeNullOrEmpty();
            historyItems[1].Show.Should().BeNull();
            historyItems[1].Season.Should().BeNull();
            historyItems[1].Episode.Should().BeNull();
        }
Beispiel #29
0
        public void Test_CertificationArrayJsonReader_ReadArray_From_JsonReader_Null()
        {
            var traktJsonReader = new ArrayJsonReader <ITraktCertification>();
            Func <Task <IEnumerable <ITraktCertification> > > traktCertifications = () => traktJsonReader.ReadArrayAsync(default(JsonTextReader));

            traktCertifications.Should().Throw <ArgumentNullException>();
        }
Beispiel #30
0
        public override async Task <ITraktSyncRecommendationsPostResponseNotFoundGroup> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var postResponseMoviesReader = new ArrayJsonReader <ITraktSyncRecommendationsPostMovie>();
                var postResponseShowsReader  = new ArrayJsonReader <ITraktSyncRecommendationsPostShow>();
                ITraktSyncRecommendationsPostResponseNotFoundGroup traktSyncRecommendationsPostResponseNotFoundGroup = new TraktSyncRecommendationsPostResponseNotFoundGroup();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_MOVIES:
                        traktSyncRecommendationsPostResponseNotFoundGroup.Movies = await postResponseMoviesReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SHOWS:
                        traktSyncRecommendationsPostResponseNotFoundGroup.Shows = await postResponseShowsReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktSyncRecommendationsPostResponseNotFoundGroup);
            }

            return(await Task.FromResult(default(ITraktSyncRecommendationsPostResponseNotFoundGroup)));
        }