示例#1
0
        public void Test_SeasonIdsObjectJsonWriter_WriteObject_Object_Exceptions()
        {
            var traktJsonWriter          = new SeasonIdsObjectJsonWriter();
            Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default(ITraktSeasonIds));

            action.Should().Throw <ArgumentNullException>();
        }
示例#2
0
 public async Task Test_SeasonIdsObjectJsonWriter_WriteObject_StringWriter_Exceptions()
 {
     var                   traktJsonWriter = new SeasonIdsObjectJsonWriter();
     ITraktSeasonIds       traktSeasonIds  = new TraktSeasonIds();
     Func <Task <string> > action          = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktSeasonIds);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
示例#3
0
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktSyncRatingsPostResponseNotFoundSeason obj, CancellationToken cancellationToken = default)
        {
            if (jsonWriter == null)
            {
                throw new ArgumentNullException(nameof(jsonWriter));
            }

            await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false);

            if (obj.Rating.HasValue)
            {
                await jsonWriter.WritePropertyNameAsync(JsonProperties.SYNC_RATINGS_POST_RESPONSE_NOT_FOUND_SEASON_PROPERTY_NAME_RATING, cancellationToken).ConfigureAwait(false);

                await jsonWriter.WriteValueAsync(obj.Rating, cancellationToken).ConfigureAwait(false);
            }

            if (obj.Ids != null)
            {
                var seasonIdsObjectJsonWriter = new SeasonIdsObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.SYNC_RATINGS_POST_RESPONSE_NOT_FOUND_SEASON_PROPERTY_NAME_IDS, cancellationToken).ConfigureAwait(false);

                await seasonIdsObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Ids, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }
        public void Test_SeasonIdsObjectJsonWriter_WriteObject_JsonWriter_Exceptions()
        {
            var             traktJsonWriter = new SeasonIdsObjectJsonWriter();
            ITraktSeasonIds traktSeasonIds  = new TraktSeasonIds();
            Func <Task>     action          = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktSeasonIds);

            action.Should().Throw <ArgumentNullException>();
        }
示例#5
0
        public async Task Test_SeasonIdsObjectJsonWriter_WriteObject_Object_Only_TvRage_Property()
        {
            ITraktSeasonIds traktSeasonIds = new TraktSeasonIds
            {
                TvRage = 101
            };

            var    traktJsonWriter = new SeasonIdsObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktSeasonIds);

            json.Should().Be(@"{""trakt"":0,""tvrage"":101}");
        }
示例#6
0
        public async Task Test_SeasonIdsObjectJsonWriter_WriteObject_Object_Only_Tmdb_Property()
        {
            ITraktSeasonIds traktSeasonIds = new TraktSeasonIds
            {
                Tmdb = 789
            };

            var    traktJsonWriter = new SeasonIdsObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktSeasonIds);

            json.Should().Be(@"{""trakt"":0,""tmdb"":789}");
        }
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktPostResponseNotFoundSeason obj, CancellationToken cancellationToken = default)
        {
            CheckJsonTextWriter(jsonWriter);
            await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false);

            if (obj.Ids != null)
            {
                var seasonIdsObjectJsonWriter = new SeasonIdsObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.PROPERTY_NAME_IDS, cancellationToken).ConfigureAwait(false);

                await seasonIdsObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Ids, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }
示例#8
0
        public async Task Test_SeasonIdsObjectJsonWriter_WriteObject_StringWriter_Only_Tvdb_Property()
        {
            ITraktSeasonIds traktSeasonIds = new TraktSeasonIds
            {
                Tvdb = 456
            };

            using (var stringWriter = new StringWriter())
            {
                var    traktJsonWriter = new SeasonIdsObjectJsonWriter();
                string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktSeasonIds);

                json.Should().Be(@"{""trakt"":0,""tvdb"":456}");
            }
        }
示例#9
0
        public async Task Test_SeasonIdsObjectJsonWriter_WriteObject_Object_Complete()
        {
            ITraktSeasonIds traktSeasonIds = new TraktSeasonIds
            {
                Trakt  = 123,
                Tvdb   = 456,
                Tmdb   = 789,
                TvRage = 101
            };

            var    traktJsonWriter = new SeasonIdsObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktSeasonIds);

            json.Should().Be(@"{""trakt"":123,""tvdb"":456,""tmdb"":789,""tvrage"":101}");
        }
        public async Task Test_SeasonIdsObjectJsonWriter_WriteObject_JsonWriter_Only_TvRage_Property()
        {
            ITraktSeasonIds traktSeasonIds = new TraktSeasonIds
            {
                TvRage = 101
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new SeasonIdsObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktSeasonIds);

                    stringWriter.ToString().Should().Be(@"{""trakt"":0,""tvrage"":101}");
                }
        }
        public async Task Test_SeasonIdsObjectJsonWriter_WriteObject_JsonWriter_Complete()
        {
            ITraktSeasonIds traktSeasonIds = new TraktSeasonIds
            {
                Trakt  = 123,
                Tvdb   = 456,
                Tmdb   = 789,
                TvRage = 101
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new SeasonIdsObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktSeasonIds);

                    stringWriter.ToString().Should().Be(@"{""trakt"":123,""tvdb"":456,""tmdb"":789,""tvrage"":101}");
                }
        }
        public override async Task WriteObjectAsync(JsonTextWriter jsonWriter, ITraktUserHiddenItemsPostSeason obj, CancellationToken cancellationToken = default)
        {
            if (jsonWriter == null)
            {
                throw new ArgumentNullException(nameof(jsonWriter));
            }

            await jsonWriter.WriteStartObjectAsync(cancellationToken).ConfigureAwait(false);

            if (obj.Ids != null)
            {
                var seasonIdsObjectJsonWriter = new SeasonIdsObjectJsonWriter();
                await jsonWriter.WritePropertyNameAsync(JsonProperties.USER_HIDDEN_ITEMS_POST_SEASON_PROPERTY_NAME_IDS, cancellationToken).ConfigureAwait(false);

                await seasonIdsObjectJsonWriter.WriteObjectAsync(jsonWriter, obj.Ids, cancellationToken).ConfigureAwait(false);
            }

            await jsonWriter.WriteEndObjectAsync(cancellationToken).ConfigureAwait(false);
        }