public void Test_SeasonIdsObjectJsonReader_ReadObject_From_Json_String_Null()
        {
            var jsonReader = new SeasonIdsObjectJsonReader();
            Func <Task <ITraktSeasonIds> > traktSeasonIds = () => jsonReader.ReadObjectAsync(default(string));

            traktSeasonIds.Should().Throw <ArgumentNullException>();
        }
Пример #2
0
        public override async Task <ITraktPostResponseNotFoundSeason> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var seasonIdsReader = new SeasonIdsObjectJsonReader();
                ITraktPostResponseNotFoundSeason postResponseNotFoundSeason = new TraktPostResponseNotFoundSeason();

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

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_IDS:
                        postResponseNotFoundSeason.Ids = await seasonIdsReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(postResponseNotFoundSeason);
            }

            return(await Task.FromResult(default(ITraktPostResponseNotFoundSeason)));
        }
Пример #3
0
        public override async Task <ITraktUserHiddenItemsPostSeason> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktUserHiddenItemsPostSeason)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var seasonIdsObjectJsonReader = new SeasonIdsObjectJsonReader();
                ITraktUserHiddenItemsPostSeason hiddenItemsPostSeason = new TraktUserHiddenItemsPostSeason();

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

                    switch (propertyName)
                    {
                    case JsonProperties.USER_HIDDEN_ITEMS_POST_SEASON_PROPERTY_NAME_IDS:
                        hiddenItemsPostSeason.Ids = await seasonIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(hiddenItemsPostSeason);
            }

            return(await Task.FromResult(default(ITraktUserHiddenItemsPostSeason)));
        }
Пример #4
0
        public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_JsonReader_Null()
        {
            var traktJsonReader = new SeasonIdsObjectJsonReader();

            var traktSeasonIds = await traktJsonReader.ReadObjectAsync(default(JsonTextReader));

            traktSeasonIds.Should().BeNull();
        }
        public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_Json_String_Empty()
        {
            var jsonReader = new SeasonIdsObjectJsonReader();

            var traktSeasonIds = await jsonReader.ReadObjectAsync(string.Empty);

            traktSeasonIds.Should().BeNull();
        }
        public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_Stream_Empty()
        {
            var traktJsonReader = new SeasonIdsObjectJsonReader();

            using (var stream = string.Empty.ToStream())
            {
                var traktSeasonIds = await traktJsonReader.ReadObjectAsync(stream);

                traktSeasonIds.Should().BeNull();
            }
        }
        public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_Json_String_Not_Valid_5()
        {
            var jsonReader = new SeasonIdsObjectJsonReader();

            var traktSeasonIds = await jsonReader.ReadObjectAsync(JSON_NOT_VALID_5);

            traktSeasonIds.Should().NotBeNull();
            traktSeasonIds.Trakt.Should().Be(0);
            traktSeasonIds.Tvdb.Should().BeNull();
            traktSeasonIds.Tmdb.Should().BeNull();
            traktSeasonIds.TvRage.Should().BeNull();
        }
Пример #8
0
        public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_JsonReader_Empty()
        {
            var traktJsonReader = new SeasonIdsObjectJsonReader();

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

                    traktSeasonIds.Should().BeNull();
                }
        }
Пример #9
0
        public async Task Test_TraktSeasonIds_From_Json()
        {
            var jsonReader = new SeasonIdsObjectJsonReader();
            var seasonIds  = await jsonReader.ReadObjectAsync(JSON) as TraktSeasonIds;

            seasonIds.Should().NotBeNull();
            seasonIds.Trakt.Should().Be(61430);
            seasonIds.Tvdb.Should().Be(279121U);
            seasonIds.Tmdb.Should().Be(60523U);
            seasonIds.TvRage.Should().Be(36939U);
            seasonIds.HasAnyId.Should().BeTrue();
        }
        public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_Json_String_Complete()
        {
            var jsonReader = new SeasonIdsObjectJsonReader();

            var traktSeasonIds = await jsonReader.ReadObjectAsync(JSON_COMPLETE);

            traktSeasonIds.Should().NotBeNull();
            traktSeasonIds.Trakt.Should().Be(61430);
            traktSeasonIds.Tvdb.Should().Be(279121U);
            traktSeasonIds.Tmdb.Should().Be(60523U);
            traktSeasonIds.TvRage.Should().Be(36939U);
        }
        public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_Json_String_Incomplete_6()
        {
            var jsonReader = new SeasonIdsObjectJsonReader();

            var traktSeasonIds = await jsonReader.ReadObjectAsync(JSON_INCOMPLETE_6);

            traktSeasonIds.Should().NotBeNull();
            traktSeasonIds.Trakt.Should().Be(0);
            traktSeasonIds.Tvdb.Should().Be(279121U);
            traktSeasonIds.Tmdb.Should().BeNull();
            traktSeasonIds.TvRage.Should().BeNull();
        }
        public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_Stream_Incomplete_4()
        {
            var traktJsonReader = new SeasonIdsObjectJsonReader();

            using (var stream = JSON_INCOMPLETE_4.ToStream())
            {
                var traktSeasonIds = await traktJsonReader.ReadObjectAsync(stream);

                traktSeasonIds.Should().NotBeNull();
                traktSeasonIds.Trakt.Should().Be(61430);
                traktSeasonIds.Tvdb.Should().Be(279121U);
                traktSeasonIds.Tmdb.Should().Be(60523U);
                traktSeasonIds.TvRage.Should().BeNull();
            }
        }
        public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_Stream_Not_Valid_5()
        {
            var traktJsonReader = new SeasonIdsObjectJsonReader();

            using (var stream = JSON_NOT_VALID_5.ToStream())
            {
                var traktSeasonIds = await traktJsonReader.ReadObjectAsync(stream);

                traktSeasonIds.Should().NotBeNull();
                traktSeasonIds.Trakt.Should().Be(0);
                traktSeasonIds.Tvdb.Should().BeNull();
                traktSeasonIds.Tmdb.Should().BeNull();
                traktSeasonIds.TvRage.Should().BeNull();
            }
        }
Пример #14
0
        public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_JsonReader_Not_Valid_5()
        {
            var traktJsonReader = new SeasonIdsObjectJsonReader();

            using (var reader = new StringReader(JSON_NOT_VALID_5))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    var traktSeasonIds = await traktJsonReader.ReadObjectAsync(jsonReader);

                    traktSeasonIds.Should().NotBeNull();
                    traktSeasonIds.Trakt.Should().Be(0);
                    traktSeasonIds.Tvdb.Should().BeNull();
                    traktSeasonIds.Tmdb.Should().BeNull();
                    traktSeasonIds.TvRage.Should().BeNull();
                }
        }
Пример #15
0
        public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_JsonReader_Incomplete_4()
        {
            var traktJsonReader = new SeasonIdsObjectJsonReader();

            using (var reader = new StringReader(JSON_INCOMPLETE_4))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    var traktSeasonIds = await traktJsonReader.ReadObjectAsync(jsonReader);

                    traktSeasonIds.Should().NotBeNull();
                    traktSeasonIds.Trakt.Should().Be(61430);
                    traktSeasonIds.Tvdb.Should().Be(279121U);
                    traktSeasonIds.Tmdb.Should().Be(60523U);
                    traktSeasonIds.TvRage.Should().BeNull();
                }
        }
Пример #16
0
        public override async Task <ITraktSyncRatingsPostResponseNotFoundSeason> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktSyncRatingsPostResponseNotFoundSeason)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var seasonIdsReader = new SeasonIdsObjectJsonReader();
                ITraktSyncRatingsPostResponseNotFoundSeason syncRatingsPostResponseNotFoundSeason = new TraktSyncRatingsPostResponseNotFoundSeason();

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

                    switch (propertyName)
                    {
                    case JsonProperties.SYNC_RATINGS_POST_RESPONSE_NOT_FOUND_SEASON_PROPERTY_NAME_RATING:
                        syncRatingsPostResponseNotFoundSeason.Rating = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.SYNC_RATINGS_POST_RESPONSE_NOT_FOUND_SEASON_PROPERTY_NAME_IDS:
                        syncRatingsPostResponseNotFoundSeason.Ids = await seasonIdsReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(syncRatingsPostResponseNotFoundSeason);
            }

            return(await Task.FromResult(default(ITraktSyncRatingsPostResponseNotFoundSeason)));
        }
Пример #17
0
 public async Task Test_SeasonIdsObjectJsonReader_ReadObject_From_JsonReader_Null()
 {
     var traktJsonReader = new SeasonIdsObjectJsonReader();
     Func <Task <ITraktSeasonIds> > traktSeasonIds = () => traktJsonReader.ReadObjectAsync(default(JsonTextReader));
     await traktSeasonIds.Should().ThrowAsync <ArgumentNullException>();
 }