public async Task Test_SeasonCollectionProgressArrayJsonReader_ReadArray_From_Json_String_Empty()
        {
            var jsonReader = new SeasonCollectionProgressArrayJsonReader();

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

            traktSeasonCollectionProgresses.Should().BeNull();
        }
        public async Task Test_SeasonCollectionProgressArrayJsonReader_ReadArray_From_Json_String_Empty_Array()
        {
            var jsonReader = new SeasonCollectionProgressArrayJsonReader();

            var traktSeasonCollectionProgresses = await jsonReader.ReadArrayAsync(JSON_EMPTY_ARRAY);

            traktSeasonCollectionProgresses.Should().NotBeNull().And.BeEmpty();
        }
        public async Task Test_SeasonCollectionProgressArrayJsonReader_ReadArray_From_Json_String_Not_Valid_5()
        {
            var jsonReader = new SeasonCollectionProgressArrayJsonReader();

            var traktSeasonCollectionProgresses = await jsonReader.ReadArrayAsync(JSON_NOT_VALID_5);

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

            var collectionProgresses = traktSeasonCollectionProgresses.ToArray();

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

            var episodesCollectionProgress = collectionProgresses[0].Episodes.ToArray();

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

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

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

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

            episodesCollectionProgress = collectionProgresses[1].Episodes.ToArray();

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

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

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

            collectionProgresses[2].Number.Should().Be(3);
            collectionProgresses[2].Aired.Should().Be(3);
            collectionProgresses[2].Completed.Should().BeNull();
            collectionProgresses[2].Episodes.Should().BeNull();
        }
        public override async Task <ITraktShowCollectionProgress> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktShowCollectionProgress)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var seasonsArrayReader = new SeasonArrayJsonReader();
                var seasonCollectionProgressArrayReader = new SeasonCollectionProgressArrayJsonReader();
                var episodeObjectReader = new EpisodeObjectJsonReader();

                ITraktShowCollectionProgress traktShowCollectionProgress = new TraktShowCollectionProgress();

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

                    switch (propertyName)
                    {
                    case JsonProperties.SHOW_COLLECTION_PROGRESS_PROPERTY_NAME_AIRED:
                        traktShowCollectionProgress.Aired = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.SHOW_COLLECTION_PROGRESS_PROPERTY_NAME_COMPLETED:
                        traktShowCollectionProgress.Completed = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

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

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

                        break;
                    }

                    case JsonProperties.SHOW_COLLECTION_PROGRESS_PROPERTY_NAME_SEASONS:
                        traktShowCollectionProgress.Seasons = await seasonCollectionProgressArrayReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SHOW_COLLECTION_PROGRESS_PROPERTY_NAME_HIDDEN_SEASONS:
                        traktShowCollectionProgress.HiddenSeasons = await seasonsArrayReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SHOW_COLLECTION_PROGRESS_PROPERTY_NAME_NEXT_EPISODE:
                        traktShowCollectionProgress.NextEpisode = await episodeObjectReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.SHOW_COLLECTION_PROGRESS_PROPERTY_NAME_LAST_EPISODE:
                        traktShowCollectionProgress.LastEpisode = await episodeObjectReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(traktShowCollectionProgress);
            }

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