public async Task Test_EpisodeWatchedProgressObjectJsonWriter_WriteObject_Object_Only_LastWatchedAt_Property()
        {
            ITraktEpisodeWatchedProgress traktEpisodeWatchedProgress = new TraktEpisodeWatchedProgress
            {
                LastWatchedAt = LAST_WATCHED_AT
            };

            var    traktJsonWriter = new EpisodeWatchedProgressObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktEpisodeWatchedProgress);

            json.Should().Be($"{{\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}");
        }
        public async Task Test_EpisodeWatchedProgressObjectJsonWriter_WriteObject_Object_Complete()
        {
            ITraktEpisodeWatchedProgress traktEpisodeWatchedProgress = new TraktEpisodeWatchedProgress
            {
                Number        = 1,
                Completed     = true,
                LastWatchedAt = LAST_WATCHED_AT
            };

            var    traktJsonWriter = new EpisodeWatchedProgressObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktEpisodeWatchedProgress);

            json.Should().Be(@"{""number"":1,""completed"":true," +
                             $"\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}");
        }
        public async Task Test_SeasonWatchedProgressObjectJsonWriter_WriteObject_Object_Complete()
        {
            ITraktSeasonWatchedProgress traktSeasonWatchedProgress = new TraktSeasonWatchedProgress
            {
                Number    = 1,
                Aired     = 24,
                Completed = 12,
                Episodes  = new List <ITraktEpisodeWatchedProgress>
                {
                    new TraktEpisodeWatchedProgress
                    {
                        Number        = 1,
                        Completed     = true,
                        LastWatchedAt = LAST_WATCHED_AT
                    },
                    new TraktEpisodeWatchedProgress
                    {
                        Number        = 2,
                        Completed     = true,
                        LastWatchedAt = LAST_WATCHED_AT
                    }
                }
            };

            var    traktJsonWriter = new SeasonWatchedProgressObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktSeasonWatchedProgress);

            json.Should().Be(@"{""number"":1,""aired"":24,""completed"":12," +
                             @"""episodes"":[" +
                             $"{{\"number\":1,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}," +
                             $"{{\"number\":2,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}" +
                             "]}");
        }
Пример #4
0
        public async Task Test_SeasonWatchedProgressObjectJsonWriter_WriteObject_StringWriter_Only_Episodes_Property()
        {
            ITraktSeasonWatchedProgress traktSeasonWatchedProgress = new TraktSeasonWatchedProgress
            {
                Episodes = new List <ITraktEpisodeWatchedProgress>
                {
                    new TraktEpisodeWatchedProgress
                    {
                        Number        = 1,
                        Completed     = true,
                        LastWatchedAt = LAST_WATCHED_AT
                    },
                    new TraktEpisodeWatchedProgress
                    {
                        Number        = 2,
                        Completed     = true,
                        LastWatchedAt = LAST_WATCHED_AT
                    }
                }
            };

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

                json.Should().Be(@"{""episodes"":[" +
                                 $"{{\"number\":1,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}," +
                                 $"{{\"number\":2,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}" +
                                 "]}");
            }
        }
        public async Task Test_EpisodeWatchedProgressArrayJsonWriter_WriteArray_StringWriter_Complete()
        {
            IEnumerable <ITraktEpisodeWatchedProgress> traktEpisodeWatchedProgresss = new List <ITraktEpisodeWatchedProgress>
            {
                new TraktEpisodeWatchedProgress
                {
                    Number        = 1,
                    Completed     = true,
                    LastWatchedAt = LAST_WATCHED_AT
                },
                new TraktEpisodeWatchedProgress
                {
                    Number        = 2,
                    Completed     = true,
                    LastWatchedAt = LAST_WATCHED_AT
                },
                new TraktEpisodeWatchedProgress
                {
                    Number        = 3,
                    Completed     = true,
                    LastWatchedAt = LAST_WATCHED_AT
                }
            };

            using (var stringWriter = new StringWriter())
            {
                var    traktJsonWriter = new ArrayJsonWriter <ITraktEpisodeWatchedProgress>();
                string json            = await traktJsonWriter.WriteArrayAsync(stringWriter, traktEpisodeWatchedProgresss);

                json.Should().Be($"[{{\"number\":1,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}," +
                                 $"{{\"number\":2,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}," +
                                 $"{{\"number\":3,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}]");
            }
        }
        public async Task Test_SeasonWatchedProgressArrayJsonWriter_WriteArray_StringWriter_Complete()
        {
            IEnumerable <ITraktSeasonWatchedProgress> traktSeasonWatchedProgresses = new List <ITraktSeasonWatchedProgress>
            {
                new TraktSeasonWatchedProgress
                {
                    Number    = 1,
                    Aired     = 24,
                    Completed = 12,
                    Episodes  = new List <ITraktEpisodeWatchedProgress>
                    {
                        new TraktEpisodeWatchedProgress
                        {
                            Number        = 1,
                            Completed     = true,
                            LastWatchedAt = LAST_WATCHED_AT
                        },
                        new TraktEpisodeWatchedProgress
                        {
                            Number        = 2,
                            Completed     = true,
                            LastWatchedAt = LAST_WATCHED_AT
                        }
                    }
                },
                new TraktSeasonWatchedProgress
                {
                    Number    = 2,
                    Aired     = 24,
                    Completed = 12,
                    Episodes  = new List <ITraktEpisodeWatchedProgress>
                    {
                        new TraktEpisodeWatchedProgress
                        {
                            Number        = 1,
                            Completed     = true,
                            LastWatchedAt = LAST_WATCHED_AT
                        },
                        new TraktEpisodeWatchedProgress
                        {
                            Number        = 2,
                            Completed     = true,
                            LastWatchedAt = LAST_WATCHED_AT
                        }
                    }
                }
            };

            using (var stringWriter = new StringWriter())
            {
                var    traktJsonWriter = new ArrayJsonWriter <ITraktSeasonWatchedProgress>();
                string json            = await traktJsonWriter.WriteArrayAsync(stringWriter, traktSeasonWatchedProgresses);

                json.Should().Be(@"[{""number"":1,""aired"":24,""completed"":12," +
                                 @"""episodes"":[" +
                                 $"{{\"number\":1,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}," +
                                 $"{{\"number\":2,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}" +
                                 "]}," +
                                 @"{""number"":2,""aired"":24,""completed"":12," +
                                 @"""episodes"":[" +
                                 $"{{\"number\":1,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}," +
                                 $"{{\"number\":2,\"completed\":true,\"last_watched_at\":\"{LAST_WATCHED_AT.ToTraktLongDateTimeString()}\"}}" +
                                 "]}]");
            }
        }