Ejemplo n.º 1
0
        public async Task Test_HistoryItemArrayJsonWriter_Season_WriteArray_Array_SingleObject()
        {
            IEnumerable <ITraktHistoryItem> traktHistoryItems = new List <ITraktHistoryItem>
            {
                new TraktHistoryItem
                {
                    Id        = 1982347UL,
                    WatchedAt = WATCHED_AT,
                    Action    = TraktHistoryActionType.Checkin,
                    Type      = TraktSyncItemType.Season,
                    Season    = new TraktSeason
                    {
                        Number = 1,
                        Ids    = new TraktSeasonIds
                        {
                            Trakt  = 61430U,
                            Tvdb   = 279121U,
                            Tmdb   = 60523U,
                            TvRage = 36939U
                        }
                    }
                }
            };

            var    traktJsonWriter = new ArrayJsonWriter <ITraktHistoryItem>();
            string json            = await traktJsonWriter.WriteArrayAsync(traktHistoryItems);

            json.Should().Be(@"[{""id"":1982347," +
                             $"\"watched_at\":\"{WATCHED_AT.ToTraktLongDateTimeString()}\"," +
                             @"""action"":""checkin"",""type"":""season""," +
                             @"""season"":{""number"":1," +
                             @"""ids"":{""trakt"":61430,""tvdb"":279121,""tmdb"":60523,""tvrage"":36939}}}]");
        }
        public async Task Test_HistoryItemObjectJsonWriter_Movie_WriteObject_JsonWriter_Complete()
        {
            ITraktHistoryItem traktHistoryItem = new TraktHistoryItem
            {
                Id        = 1982347UL,
                WatchedAt = WATCHED_AT,
                Action    = TraktHistoryActionType.Checkin,
                Type      = TraktSyncItemType.Movie,
                Movie     = new TraktMovie
                {
                    Title = "Star Wars: The Force Awakens",
                    Year  = 2015,
                    Ids   = new TraktMovieIds
                    {
                        Trakt = 94024U,
                        Slug  = "star-wars-the-force-awakens-2015",
                        Imdb  = "tt2488496",
                        Tmdb  = 140607U
                    }
                }
            };

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

                    stringWriter.ToString().Should().Be(@"{""id"":1982347," +
                                                        $"\"watched_at\":\"{WATCHED_AT.ToTraktLongDateTimeString()}\"," +
                                                        @"""action"":""checkin"",""type"":""movie""," +
                                                        @"""movie"":{""title"":""Star Wars: The Force Awakens"",""year"":2015," +
                                                        @"""ids"":{""trakt"":94024,""slug"":""star-wars-the-force-awakens-2015"",""imdb"":""tt2488496"",""tmdb"":140607}}}");
                }
        }
Ejemplo n.º 3
0
        public async Task Test_HistoryItemObjectJsonWriter_Season_WriteObject_JsonWriter_Complete()
        {
            ITraktHistoryItem traktHistoryItem = new TraktHistoryItem
            {
                Id        = 1982347UL,
                WatchedAt = WATCHED_AT,
                Action    = TraktHistoryActionType.Checkin,
                Type      = TraktSyncItemType.Season,
                Season    = new TraktSeason
                {
                    Number = 1,
                    Ids    = new TraktSeasonIds
                    {
                        Trakt  = 61430U,
                        Tvdb   = 279121U,
                        Tmdb   = 60523U,
                        TvRage = 36939U
                    }
                }
            };

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

                    stringWriter.ToString().Should().Be(@"{""id"":1982347," +
                                                        $"\"watched_at\":\"{WATCHED_AT.ToTraktLongDateTimeString()}\"," +
                                                        @"""action"":""checkin"",""type"":""season""," +
                                                        @"""season"":{""number"":1," +
                                                        @"""ids"":{""trakt"":61430,""tvdb"":279121,""tmdb"":60523,""tvrage"":36939}}}");
                }
        }
Ejemplo n.º 4
0
        public async Task Test_HistoryItemArrayJsonWriter_Movie_WriteArray_Array_SingleObject()
        {
            IEnumerable <ITraktHistoryItem> traktHistoryItems = new List <ITraktHistoryItem>
            {
                new TraktHistoryItem
                {
                    Id        = 1982347UL,
                    WatchedAt = WATCHED_AT,
                    Action    = TraktHistoryActionType.Checkin,
                    Type      = TraktSyncItemType.Movie,
                    Movie     = new TraktMovie
                    {
                        Title = "Star Wars: The Force Awakens",
                        Year  = 2015,
                        Ids   = new TraktMovieIds
                        {
                            Trakt = 94024U,
                            Slug  = "star-wars-the-force-awakens-2015",
                            Imdb  = "tt2488496",
                            Tmdb  = 140607U
                        }
                    }
                }
            };

            var    traktJsonWriter = new ArrayJsonWriter <ITraktHistoryItem>();
            string json            = await traktJsonWriter.WriteArrayAsync(traktHistoryItems);

            json.Should().Be(@"[{""id"":1982347," +
                             $"\"watched_at\":\"{WATCHED_AT.ToTraktLongDateTimeString()}\"," +
                             @"""action"":""checkin"",""type"":""movie""," +
                             @"""movie"":{""title"":""Star Wars: The Force Awakens"",""year"":2015," +
                             @"""ids"":{""trakt"":94024,""slug"":""star-wars-the-force-awakens-2015"",""imdb"":""tt2488496"",""tmdb"":140607}}}]");
        }
        public async Task Test_HistoryItemArrayJsonWriter_Episode_WriteArray_StringWriter_SingleObject()
        {
            IEnumerable <ITraktHistoryItem> traktHistoryItems = new List <ITraktHistoryItem>
            {
                new TraktHistoryItem
                {
                    Id        = 1982347UL,
                    WatchedAt = WATCHED_AT,
                    Action    = TraktHistoryActionType.Checkin,
                    Type      = TraktSyncItemType.Episode,
                    Episode   = new TraktEpisode
                    {
                        SeasonNumber = 1,
                        Number       = 1,
                        Title        = "Winter Is Coming",
                        Ids          = new TraktEpisodeIds
                        {
                            Trakt  = 73640U,
                            Tvdb   = 3254641U,
                            Imdb   = "tt1480055",
                            Tmdb   = 63056U,
                            TvRage = 1065008299U
                        }
                    },
                    Show = new TraktShow
                    {
                        Title = "Game of Thrones",
                        Year  = 2011,
                        Ids   = new TraktShowIds
                        {
                            Trakt  = 1390U,
                            Slug   = "game-of-thrones",
                            Tvdb   = 121361U,
                            Imdb   = "tt0944947",
                            Tmdb   = 1399U,
                            TvRage = 24493U
                        }
                    }
                }
            };

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

                json.Should().Be(@"[{""id"":1982347," +
                                 $"\"watched_at\":\"{WATCHED_AT.ToTraktLongDateTimeString()}\"," +
                                 @"""action"":""checkin"",""type"":""episode""," +
                                 @"""show"":{""title"":""Game of Thrones"",""year"":2011," +
                                 @"""ids"":{""trakt"":1390,""slug"":""game-of-thrones"",""tvdb"":121361," +
                                 @"""imdb"":""tt0944947"",""tmdb"":1399,""tvrage"":24493}}," +
                                 @"""episode"":{""season"":1,""number"":1,""title"":""Winter Is Coming""," +
                                 @"""ids"":{""trakt"":73640,""tvdb"":3254641,""imdb"":""tt1480055"",""tmdb"":63056,""tvrage"":1065008299}}}]");
            }
        }
        public async Task Test_HistoryItemObjectJsonWriter_Episode_WriteObject_StringWriter_Only_WatchedAt_Property()
        {
            ITraktHistoryItem traktHistoryItem = new TraktHistoryItem
            {
                WatchedAt = WATCHED_AT
            };

            using (var stringWriter = new StringWriter())
            {
                var traktJsonWriter = new HistoryItemObjectJsonWriter();
                string json = await traktJsonWriter.WriteObjectAsync(stringWriter, traktHistoryItem);
                json.Should().Be($"{{\"id\":0,\"watched_at\":\"{WATCHED_AT.ToTraktLongDateTimeString()}\"}}");
            }
        }
        public async Task Test_HistoryItemArrayJsonWriter_Show_WriteArray_JsonWriter_SingleObject()
        {
            IEnumerable <ITraktHistoryItem> traktHistoryItems = new List <ITraktHistoryItem>
            {
                new TraktHistoryItem
                {
                    Id        = 1982347UL,
                    WatchedAt = WATCHED_AT,
                    Action    = TraktHistoryActionType.Checkin,
                    Type      = TraktSyncItemType.Show,
                    Show      = new TraktShow
                    {
                        Title = "Game of Thrones",
                        Year  = 2011,
                        Ids   = new TraktShowIds
                        {
                            Trakt  = 1390U,
                            Slug   = "game-of-thrones",
                            Tvdb   = 121361U,
                            Imdb   = "tt0944947",
                            Tmdb   = 1399U,
                            TvRage = 24493U
                        }
                    }
                }
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new ArrayJsonWriter <ITraktHistoryItem>();
                    await traktJsonWriter.WriteArrayAsync(jsonWriter, traktHistoryItems);

                    stringWriter.ToString().Should().Be(@"[{""id"":1982347," +
                                                        $"\"watched_at\":\"{WATCHED_AT.ToTraktLongDateTimeString()}\"," +
                                                        @"""action"":""checkin"",""type"":""show""," +
                                                        @"""show"":{""title"":""Game of Thrones"",""year"":2011," +
                                                        @"""ids"":{""trakt"":1390,""slug"":""game-of-thrones"",""tvdb"":121361," +
                                                        @"""imdb"":""tt0944947"",""tmdb"":1399,""tvrage"":24493}}}]");
                }
        }
Ejemplo n.º 8
0
        public async Task Test_HistoryItemObjectJsonWriter_Show_WriteObject_StringWriter_Complete()
        {
            ITraktHistoryItem traktHistoryItem = new TraktHistoryItem
            {
                Id        = 1982347UL,
                WatchedAt = WATCHED_AT,
                Action    = TraktHistoryActionType.Checkin,
                Type      = TraktSyncItemType.Show,
                Show      = new TraktShow
                {
                    Title = "Game of Thrones",
                    Year  = 2011,
                    Ids   = new TraktShowIds
                    {
                        Trakt  = 1390U,
                        Slug   = "game-of-thrones",
                        Tvdb   = 121361U,
                        Imdb   = "tt0944947",
                        Tmdb   = 1399U,
                        TvRage = 24493U
                    }
                }
            };

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

                json.Should().Be(@"{""id"":1982347," +
                                 $"\"watched_at\":\"{WATCHED_AT.ToTraktLongDateTimeString()}\"," +
                                 @"""action"":""checkin"",""type"":""show""," +
                                 @"""show"":{""title"":""Game of Thrones"",""year"":2011," +
                                 @"""ids"":{""trakt"":1390,""slug"":""game-of-thrones"",""tvdb"":121361," +
                                 @"""imdb"":""tt0944947"",""tmdb"":1399,""tvrage"":24493}}}");
            }
        }