Exemplo n.º 1
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_Json_String_Not_Valid_6()
        {
            var jsonReader = new ShowIdsObjectJsonReader();

            var traktShowIds = await jsonReader.ReadObjectAsync(JSON_NOT_VALID_6);

            traktShowIds.Should().NotBeNull();
            traktShowIds.Trakt.Should().Be(1390);
            traktShowIds.Slug.Should().Be("game-of-thrones");
            traktShowIds.Tvdb.Should().Be(121361U);
            traktShowIds.Imdb.Should().Be("tt0944947");
            traktShowIds.Tmdb.Should().Be(1399U);
            traktShowIds.TvRage.Should().BeNull();
        }
Exemplo n.º 2
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_Json_String_Not_Valid_7()
        {
            var jsonReader = new ShowIdsObjectJsonReader();

            var traktShowIds = await jsonReader.ReadObjectAsync(JSON_NOT_VALID_7);

            traktShowIds.Should().NotBeNull();
            traktShowIds.Trakt.Should().Be(0);
            traktShowIds.Slug.Should().BeNull();
            traktShowIds.Tvdb.Should().BeNull();
            traktShowIds.Imdb.Should().BeNull();
            traktShowIds.Tmdb.Should().BeNull();
            traktShowIds.TvRage.Should().BeNull();
        }
Exemplo n.º 3
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_Json_String_Incomplete_12()
        {
            var jsonReader = new ShowIdsObjectJsonReader();

            var traktShowIds = await jsonReader.ReadObjectAsync(JSON_INCOMPLETE_12);

            traktShowIds.Should().NotBeNull();
            traktShowIds.Trakt.Should().Be(0);
            traktShowIds.Slug.Should().BeNull();
            traktShowIds.Tvdb.Should().BeNull();
            traktShowIds.Imdb.Should().BeNull();
            traktShowIds.Tmdb.Should().BeNull();
            traktShowIds.TvRage.Should().Be(24493U);
        }
Exemplo n.º 4
0
        public async Task Test_TraktShowIds_From_Json()
        {
            var jsonReader = new ShowIdsObjectJsonReader();
            var showIds    = await jsonReader.ReadObjectAsync(JSON) as TraktShowIds;

            showIds.Should().NotBeNull();
            showIds.Trakt.Should().Be(1390);
            showIds.Slug.Should().Be("game-of-thrones");
            showIds.Tvdb.Should().Be(121361U);
            showIds.Imdb.Should().Be("tt0944947");
            showIds.Tmdb.Should().Be(1399U);
            showIds.TvRage.Should().Be(24493U);
            showIds.HasAnyId.Should().BeTrue();
        }
Exemplo n.º 5
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_Json_String_Incomplete_4()
        {
            var jsonReader = new ShowIdsObjectJsonReader();

            var traktShowIds = await jsonReader.ReadObjectAsync(JSON_INCOMPLETE_4);

            traktShowIds.Should().NotBeNull();
            traktShowIds.Trakt.Should().Be(1390);
            traktShowIds.Slug.Should().Be("game-of-thrones");
            traktShowIds.Tvdb.Should().Be(121361U);
            traktShowIds.Imdb.Should().BeNull();
            traktShowIds.Tmdb.Should().Be(1399U);
            traktShowIds.TvRage.Should().Be(24493U);
        }
Exemplo n.º 6
0
        public override async Task <ITraktUserHiddenItemsPostShow> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var showIdsObjectJsonReader = new ShowIdsObjectJsonReader();
                var seasonArrayJsonReader   = new ArrayJsonReader <ITraktUserHiddenItemsPostShowSeason>();
                ITraktUserHiddenItemsPostShow hiddenItemsPostShow = new TraktUserHiddenItemsPostShow();

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

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_TITLE:
                        hiddenItemsPostShow.Title = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_YEAR:
                        hiddenItemsPostShow.Year = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_IDS:
                        hiddenItemsPostShow.Ids = await showIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SEASONS:
                        hiddenItemsPostShow.Seasons = await seasonArrayJsonReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(hiddenItemsPostShow);
            }

            return(await Task.FromResult(default(ITraktUserHiddenItemsPostShow)));
        }
        public override async Task <ITraktSyncRecommendationsPostShow> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktSyncRecommendationsPostShow traktSyncRecommendationsPostShow = new TraktSyncRecommendationsPostShow();
                var showIdsObjectJsonReader = new ShowIdsObjectJsonReader();

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

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_TITLE:
                        traktSyncRecommendationsPostShow.Title = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_YEAR:
                        traktSyncRecommendationsPostShow.Year = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_IDS:
                        traktSyncRecommendationsPostShow.Ids = await showIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_NOTES:
                        traktSyncRecommendationsPostShow.Notes = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(traktSyncRecommendationsPostShow);
            }

            return(await Task.FromResult(default(ITraktSyncRecommendationsPostShow)));
        }
Exemplo n.º 8
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_Stream_Incomplete_10()
        {
            var traktJsonReader = new ShowIdsObjectJsonReader();

            using (var stream = JSON_INCOMPLETE_10.ToStream())
            {
                var traktShowIds = await traktJsonReader.ReadObjectAsync(stream);

                traktShowIds.Should().NotBeNull();
                traktShowIds.Trakt.Should().Be(0);
                traktShowIds.Slug.Should().BeNull();
                traktShowIds.Tvdb.Should().BeNull();
                traktShowIds.Imdb.Should().Be("tt0944947");
                traktShowIds.Tmdb.Should().BeNull();
                traktShowIds.TvRage.Should().BeNull();
            }
        }
Exemplo n.º 9
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_Stream_Not_Valid_6()
        {
            var traktJsonReader = new ShowIdsObjectJsonReader();

            using (var stream = JSON_NOT_VALID_6.ToStream())
            {
                var traktShowIds = await traktJsonReader.ReadObjectAsync(stream);

                traktShowIds.Should().NotBeNull();
                traktShowIds.Trakt.Should().Be(1390);
                traktShowIds.Slug.Should().Be("game-of-thrones");
                traktShowIds.Tvdb.Should().Be(121361U);
                traktShowIds.Imdb.Should().Be("tt0944947");
                traktShowIds.Tmdb.Should().Be(1399U);
                traktShowIds.TvRage.Should().BeNull();
            }
        }
Exemplo n.º 10
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_Stream_Not_Valid_7()
        {
            var traktJsonReader = new ShowIdsObjectJsonReader();

            using (var stream = JSON_NOT_VALID_7.ToStream())
            {
                var traktShowIds = await traktJsonReader.ReadObjectAsync(stream);

                traktShowIds.Should().NotBeNull();
                traktShowIds.Trakt.Should().Be(0);
                traktShowIds.Slug.Should().BeNull();
                traktShowIds.Tvdb.Should().BeNull();
                traktShowIds.Imdb.Should().BeNull();
                traktShowIds.Tmdb.Should().BeNull();
                traktShowIds.TvRage.Should().BeNull();
            }
        }
Exemplo n.º 11
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_Stream_Incomplete_4()
        {
            var traktJsonReader = new ShowIdsObjectJsonReader();

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

                traktShowIds.Should().NotBeNull();
                traktShowIds.Trakt.Should().Be(1390);
                traktShowIds.Slug.Should().Be("game-of-thrones");
                traktShowIds.Tvdb.Should().Be(121361U);
                traktShowIds.Imdb.Should().BeNull();
                traktShowIds.Tmdb.Should().Be(1399U);
                traktShowIds.TvRage.Should().Be(24493U);
            }
        }
Exemplo n.º 12
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_JsonReader_Incomplete_9()
        {
            var traktJsonReader = new ShowIdsObjectJsonReader();

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

                    traktShowIds.Should().NotBeNull();
                    traktShowIds.Trakt.Should().Be(0);
                    traktShowIds.Slug.Should().BeNull();
                    traktShowIds.Tvdb.Should().Be(121361U);
                    traktShowIds.Imdb.Should().BeNull();
                    traktShowIds.Tmdb.Should().BeNull();
                    traktShowIds.TvRage.Should().BeNull();
                }
        }
Exemplo n.º 13
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_JsonReader_Incomplete_3()
        {
            var traktJsonReader = new ShowIdsObjectJsonReader();

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

                    traktShowIds.Should().NotBeNull();
                    traktShowIds.Trakt.Should().Be(1390);
                    traktShowIds.Slug.Should().Be("game-of-thrones");
                    traktShowIds.Tvdb.Should().BeNull();
                    traktShowIds.Imdb.Should().Be("tt0944947");
                    traktShowIds.Tmdb.Should().Be(1399U);
                    traktShowIds.TvRage.Should().Be(24493U);
                }
        }
Exemplo n.º 14
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_JsonReader_Not_Valid_7()
        {
            var traktJsonReader = new ShowIdsObjectJsonReader();

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

                    traktShowIds.Should().NotBeNull();
                    traktShowIds.Trakt.Should().Be(0);
                    traktShowIds.Slug.Should().BeNull();
                    traktShowIds.Tvdb.Should().BeNull();
                    traktShowIds.Imdb.Should().BeNull();
                    traktShowIds.Tmdb.Should().BeNull();
                    traktShowIds.TvRage.Should().BeNull();
                }
        }
Exemplo n.º 15
0
        public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_JsonReader_Not_Valid_5()
        {
            var traktJsonReader = new ShowIdsObjectJsonReader();

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

                    traktShowIds.Should().NotBeNull();
                    traktShowIds.Trakt.Should().Be(1390);
                    traktShowIds.Slug.Should().Be("game-of-thrones");
                    traktShowIds.Tvdb.Should().Be(121361U);
                    traktShowIds.Imdb.Should().Be("tt0944947");
                    traktShowIds.Tmdb.Should().BeNull();
                    traktShowIds.TvRage.Should().Be(24493U);
                }
        }
        public override async Task <ITraktUserCustomListItemsPostShow> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktUserCustomListItemsPostShow)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var showIdsObjectJsonReader = new ShowIdsObjectJsonReader();
                var seasonArrayJsonReader   = new UserCustomListItemsPostShowSeasonArrayJsonReader();
                ITraktUserCustomListItemsPostShow customListItemsPostShow = new TraktUserCustomListItemsPostShow();

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

                    switch (propertyName)
                    {
                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_SHOW_PROPERTY_NAME_IDS:
                        customListItemsPostShow.Ids = await showIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.USER_CUSTOM_LIST_ITEMS_POST_SHOW_PROPERTY_NAME_SEASONS:
                        customListItemsPostShow.Seasons = await seasonArrayJsonReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(customListItemsPostShow);
            }

            return(await Task.FromResult(default(ITraktUserCustomListItemsPostShow)));
        }
Exemplo n.º 17
0
        public override async Task <ITraktSyncRatingsPostResponseNotFoundShow> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktSyncRatingsPostResponseNotFoundShow)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var showIdsReader = new ShowIdsObjectJsonReader();
                ITraktSyncRatingsPostResponseNotFoundShow syncRatingsPostResponseNotFoundShow = new TraktSyncRatingsPostResponseNotFoundShow();

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

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

                        break;

                    case JsonProperties.SYNC_RATINGS_POST_RESPONSE_NOT_FOUND_SHOW_PROPERTY_NAME_IDS:
                        syncRatingsPostResponseNotFoundShow.Ids = await showIdsReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(syncRatingsPostResponseNotFoundShow);
            }

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

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var showIdsObjectJsonReader = new ShowIdsObjectJsonReader();
                var seasonArrayJsonReader   = new SyncHistoryPostShowSeasonArrayJsonReader();
                ITraktSyncHistoryPostShow syncHistoryPostShow = new TraktSyncHistoryPostShow();

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

                    switch (propertyName)
                    {
                    case JsonProperties.SYNC_HISTORY_POST_SHOW_PROPERTY_NAME_WATCHED_AT:
                    {
                        Pair <bool, DateTime> value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            syncHistoryPostShow.WatchedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.SYNC_HISTORY_POST_SHOW_PROPERTY_NAME_TITLE:
                        syncHistoryPostShow.Title = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.SYNC_HISTORY_POST_SHOW_PROPERTY_NAME_YEAR:
                        syncHistoryPostShow.Year = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.SYNC_HISTORY_POST_SHOW_PROPERTY_NAME_IDS:
                        syncHistoryPostShow.Ids = await showIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SYNC_HISTORY_POST_SHOW_PROPERTY_NAME_SEASONS:
                        syncHistoryPostShow.Seasons = await seasonArrayJsonReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(syncHistoryPostShow);
            }

            return(await Task.FromResult(default(ITraktSyncHistoryPostShow)));
        }
Exemplo n.º 19
0
        public override async Task <ITraktSyncCollectionPostShow> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktSyncCollectionPostShow traktSyncCollectionPostShow = new TraktSyncCollectionPostShow();
                var showIdsObjectJsonReader = new ShowIdsObjectJsonReader();
                var syncCollectionPostShowSeasonArrayJsonReader = new ArrayJsonReader <ITraktSyncCollectionPostShowSeason>();

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

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_COLLECTED_AT:
                    {
                        Pair <bool, DateTime> value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktSyncCollectionPostShow.CollectedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_TITLE:
                        traktSyncCollectionPostShow.Title = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_YEAR:
                        traktSyncCollectionPostShow.Year = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_IDS:
                        traktSyncCollectionPostShow.Ids = await showIdsObjectJsonReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SEASONS:
                        traktSyncCollectionPostShow.Seasons = await syncCollectionPostShowSeasonArrayJsonReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_MEDIA_TYPE:
                        traktSyncCollectionPostShow.MediaType = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaType>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_RESOLUTION:
                        traktSyncCollectionPostShow.MediaResolution = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaResolution>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_AUDIO:
                        traktSyncCollectionPostShow.Audio = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaAudio>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_AUDIO_CHANNELS:
                        traktSyncCollectionPostShow.AudioChannels = await JsonReaderHelper.ReadEnumerationValueAsync <TraktMediaAudioChannel>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_3D:
                        traktSyncCollectionPostShow.ThreeDimensional = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(traktSyncCollectionPostShow);
            }

            return(await Task.FromResult(default(ITraktSyncCollectionPostShow)));
        }
 public async Task Test_ShowIdsObjectJsonReader_ReadObject_From_Json_String_Null()
 {
     var jsonReader = new ShowIdsObjectJsonReader();
     Func <Task <ITraktShowIds> > traktShowIds = () => jsonReader.ReadObjectAsync(default(string));
     await traktShowIds.Should().ThrowAsync <ArgumentNullException>();
 }