public async Task Test_PostResponseNotFoundMovieArrayJsonReader_ReadArray_From_JsonReader_Complete()
        {
            var traktJsonReader = new PostResponseNotFoundMovieArrayJsonReader();

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

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

                    var notFoundMovie = notFoundMovies.ToArray();

                    notFoundMovie[0].Should().NotBeNull();
                    notFoundMovie[0].Ids.Should().NotBeNull();
                    notFoundMovie[0].Ids.Trakt.Should().Be(94024U);
                    notFoundMovie[0].Ids.Slug.Should().Be("star-wars-the-force-awakens-2015");
                    notFoundMovie[0].Ids.Imdb.Should().Be("tt2488496");
                    notFoundMovie[0].Ids.Tmdb.Should().Be(140607U);

                    notFoundMovie[1].Should().NotBeNull();
                    notFoundMovie[1].Ids.Should().NotBeNull();
                    notFoundMovie[1].Ids.Trakt.Should().Be(172687U);
                    notFoundMovie[1].Ids.Slug.Should().Be("king-arthur-legend-of-the-sword-2017");
                    notFoundMovie[1].Ids.Imdb.Should().Be("tt1972591");
                    notFoundMovie[1].Ids.Tmdb.Should().Be(274857U);
                }
        }
Exemplo 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)));
        }
        public async Task Test_PostResponseNotFoundMovieArrayJsonReader_ReadArray_From_JsonReader_Null()
        {
            var traktJsonReader = new PostResponseNotFoundMovieArrayJsonReader();

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

            notFoundMovies.Should().BeNull();
        }
        public async Task Test_PostResponseNotFoundMovieArrayJsonReader_ReadArray_From_Stream_Null()
        {
            var jsonReader = new PostResponseNotFoundMovieArrayJsonReader();

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

            notFoundMovies.Should().BeNull();
        }
        public async Task Test_PostResponseNotFoundMovieArrayJsonReader_ReadArray_From_Json_String_Empty()
        {
            var jsonReader = new PostResponseNotFoundMovieArrayJsonReader();

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

            notFoundMovies.Should().BeNull();
        }
        public async Task Test_PostResponseNotFoundMovieArrayJsonReader_ReadArray_From_Json_String_Empty_Array()
        {
            var jsonReader = new PostResponseNotFoundMovieArrayJsonReader();

            var notFoundMovies = await jsonReader.ReadArrayAsync(JSON_EMPTY_ARRAY);

            notFoundMovies.Should().NotBeNull().And.BeEmpty();
        }
        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_PostResponseNotFoundMovieArrayJsonReader_ReadArray_From_Stream_Empty()
        {
            var jsonReader = new PostResponseNotFoundMovieArrayJsonReader();

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

                notFoundMovies.Should().BeNull();
            }
        }
        public async Task Test_PostResponseNotFoundMovieArrayJsonReader_ReadArray_From_Stream_Empty_Array()
        {
            var jsonReader = new PostResponseNotFoundMovieArrayJsonReader();

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

                notFoundMovies.Should().NotBeNull().And.BeEmpty();
            }
        }
        public async Task Test_PostResponseNotFoundMovieArrayJsonReader_ReadArray_From_JsonReader_Empty()
        {
            var traktJsonReader = new PostResponseNotFoundMovieArrayJsonReader();

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

                    notFoundMovies.Should().BeNull();
                }
        }
        public async Task Test_PostResponseNotFoundMovieArrayJsonReader_ReadArray_From_Json_String_Not_Valid()
        {
            var jsonReader = new PostResponseNotFoundMovieArrayJsonReader();

            var notFoundMovies = await jsonReader.ReadArrayAsync(JSON_NOT_VALID);

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

            var notFoundMovie = notFoundMovies.ToArray();

            notFoundMovie[0].Should().NotBeNull();
            notFoundMovie[0].Ids.Should().NotBeNull();
            notFoundMovie[0].Ids.Trakt.Should().Be(94024U);
            notFoundMovie[0].Ids.Slug.Should().Be("star-wars-the-force-awakens-2015");
            notFoundMovie[0].Ids.Imdb.Should().Be("tt2488496");
            notFoundMovie[0].Ids.Tmdb.Should().Be(140607U);

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