Ejemplo n.º 1
0
        public async Task Test_PostResponseNotFoundSeasonArrayJsonReader_ReadArray_From_JsonReader_Complete()
        {
            var traktJsonReader = new PostResponseNotFoundSeasonArrayJsonReader();

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

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

                    var notFoundSeason = notFoundSeasons.ToArray();

                    notFoundSeason[0].Should().NotBeNull();
                    notFoundSeason[0].Ids.Should().NotBeNull();
                    notFoundSeason[0].Ids.Trakt.Should().Be(61430U);
                    notFoundSeason[0].Ids.Tvdb.Should().Be(279121U);
                    notFoundSeason[0].Ids.Tmdb.Should().Be(60523U);
                    notFoundSeason[0].Ids.TvRage.Should().Be(36939U);

                    notFoundSeason[1].Should().NotBeNull();
                    notFoundSeason[1].Ids.Should().NotBeNull();
                    notFoundSeason[1].Ids.Trakt.Should().Be(61431U);
                    notFoundSeason[1].Ids.Tvdb.Should().Be(578373U);
                    notFoundSeason[1].Ids.Tmdb.Should().Be(60524U);
                    notFoundSeason[1].Ids.TvRage.Should().Be(36940U);
                }
        }
Ejemplo n.º 2
0
        public override async Task <ITraktUserCustomListItemsPostResponseNotFoundGroup> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktUserCustomListItemsPostResponseNotFoundGroup)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var notFoundMoviesReader   = new PostResponseNotFoundMovieArrayJsonReader();
                var notFoundShowsReader    = new PostResponseNotFoundShowArrayJsonReader();
                var notFoundSeasonsReader  = new PostResponseNotFoundSeasonArrayJsonReader();
                var notFoundEpisodesReader = new PostResponseNotFoundEpisodeArrayJsonReader();
                var notFoundPeopleReader   = new PostResponseNotFoundPersonArrayJsonReader();
                ITraktUserCustomListItemsPostResponseNotFoundGroup customListItemsPostResponseNotFoundGroup = new TraktUserCustomListItemsPostResponseNotFoundGroup();

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

                    switch (propertyName)
                    {
                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_MOVIES:
                        customListItemsPostResponseNotFoundGroup.Movies = await notFoundMoviesReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_SHOWS:
                        customListItemsPostResponseNotFoundGroup.Shows = await notFoundShowsReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_SEASONS:
                        customListItemsPostResponseNotFoundGroup.Seasons = await notFoundSeasonsReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_EPISODES:
                        customListItemsPostResponseNotFoundGroup.Episodes = await notFoundEpisodesReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_PEOPLE:
                        customListItemsPostResponseNotFoundGroup.People = await notFoundPeopleReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(customListItemsPostResponseNotFoundGroup);
            }

            return(await Task.FromResult(default(ITraktUserCustomListItemsPostResponseNotFoundGroup)));
        }
Ejemplo n.º 3
0
        public async Task Test_PostResponseNotFoundSeasonArrayJsonReader_ReadArray_From_Json_String_Empty()
        {
            var jsonReader = new PostResponseNotFoundSeasonArrayJsonReader();

            var notFoundSeasons = await jsonReader.ReadArrayAsync(string.Empty);

            notFoundSeasons.Should().BeNull();
        }
Ejemplo n.º 4
0
        public async Task Test_PostResponseNotFoundSeasonArrayJsonReader_ReadArray_From_Json_String_Empty_Array()
        {
            var jsonReader = new PostResponseNotFoundSeasonArrayJsonReader();

            var notFoundSeasons = await jsonReader.ReadArrayAsync(JSON_EMPTY_ARRAY);

            notFoundSeasons.Should().NotBeNull().And.BeEmpty();
        }
Ejemplo n.º 5
0
        public async Task Test_PostResponseNotFoundSeasonArrayJsonReader_ReadArray_From_JsonReader_Null()
        {
            var traktJsonReader = new PostResponseNotFoundSeasonArrayJsonReader();

            var notFoundSeasons = await traktJsonReader.ReadArrayAsync(default(JsonTextReader));

            notFoundSeasons.Should().BeNull();
        }
        public async Task Test_PostResponseNotFoundSeasonArrayJsonReader_ReadArray_From_Stream_Null()
        {
            var jsonReader = new PostResponseNotFoundSeasonArrayJsonReader();

            var notFoundSeasons = await jsonReader.ReadArrayAsync(default(Stream));

            notFoundSeasons.Should().BeNull();
        }
        public override async Task <ITraktSyncHistoryRemovePostResponseNotFoundGroup> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktSyncHistoryRemovePostResponseNotFoundGroup)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var notFoundMoviesReader   = new PostResponseNotFoundMovieArrayJsonReader();
                var notFoundShowsReader    = new PostResponseNotFoundShowArrayJsonReader();
                var notFoundSeasonsReader  = new PostResponseNotFoundSeasonArrayJsonReader();
                var notFoundEpisodesReader = new PostResponseNotFoundEpisodeArrayJsonReader();
                ITraktSyncHistoryRemovePostResponseNotFoundGroup syncHistoryRemovePostResponseNotFoundGroup = new TraktSyncHistoryRemovePostResponseNotFoundGroup();

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

                    switch (propertyName)
                    {
                    case JsonProperties.SYNC_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_MOVIES:
                        syncHistoryRemovePostResponseNotFoundGroup.Movies = await notFoundMoviesReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SYNC_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_SHOWS:
                        syncHistoryRemovePostResponseNotFoundGroup.Shows = await notFoundShowsReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SYNC_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_SEASONS:
                        syncHistoryRemovePostResponseNotFoundGroup.Seasons = await notFoundSeasonsReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SYNC_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_EPISODES:
                        syncHistoryRemovePostResponseNotFoundGroup.Episodes = await notFoundEpisodesReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SYNC_HISTORY_REMOVE_POST_RESPONSE_NOT_FOUND_GROUP_PROPERTY_NAME_IDS:
                        syncHistoryRemovePostResponseNotFoundGroup.HistoryIds = await JsonReaderHelper.ReadUnsignedLongArrayAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(syncHistoryRemovePostResponseNotFoundGroup);
            }

            return(await Task.FromResult(default(ITraktSyncHistoryRemovePostResponseNotFoundGroup)));
        }
        public async Task Test_PostResponseNotFoundSeasonArrayJsonReader_ReadArray_From_Stream_Empty()
        {
            var jsonReader = new PostResponseNotFoundSeasonArrayJsonReader();

            using (var stream = string.Empty.ToStream())
            {
                var notFoundSeasons = await jsonReader.ReadArrayAsync(stream);

                notFoundSeasons.Should().BeNull();
            }
        }
        public async Task Test_PostResponseNotFoundSeasonArrayJsonReader_ReadArray_From_Stream_Empty_Array()
        {
            var jsonReader = new PostResponseNotFoundSeasonArrayJsonReader();

            using (var stream = JSON_EMPTY_ARRAY.ToStream())
            {
                var notFoundSeasons = await jsonReader.ReadArrayAsync(stream);

                notFoundSeasons.Should().NotBeNull().And.BeEmpty();
            }
        }
Ejemplo n.º 10
0
        public async Task Test_PostResponseNotFoundSeasonArrayJsonReader_ReadArray_From_JsonReader_Empty()
        {
            var traktJsonReader = new PostResponseNotFoundSeasonArrayJsonReader();

            using (var reader = new StringReader(string.Empty))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    var notFoundSeasons = await traktJsonReader.ReadArrayAsync(jsonReader);

                    notFoundSeasons.Should().BeNull();
                }
        }
Ejemplo n.º 11
0
        public async Task Test_PostResponseNotFoundSeasonArrayJsonReader_ReadArray_From_Json_String_Not_Valid()
        {
            var jsonReader = new PostResponseNotFoundSeasonArrayJsonReader();

            var notFoundSeasons = await jsonReader.ReadArrayAsync(JSON_NOT_VALID);

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

            var notFoundSeason = notFoundSeasons.ToArray();

            notFoundSeason[0].Should().NotBeNull();
            notFoundSeason[0].Ids.Should().NotBeNull();
            notFoundSeason[0].Ids.Trakt.Should().Be(61430U);
            notFoundSeason[0].Ids.Tvdb.Should().Be(279121U);
            notFoundSeason[0].Ids.Tmdb.Should().Be(60523U);
            notFoundSeason[0].Ids.TvRage.Should().Be(36939U);

            notFoundSeason[1].Should().NotBeNull();
            notFoundSeason[1].Ids.Should().BeNull();
        }