public async Task Test_CommentItemObjectJsonWriter_WriteObject_StringWriter_Only_List_Property()
        {
            ITraktCommentItem traktCommentItem = new TraktCommentItem
            {
                List = new TraktList
                {
                    Name           = "Star Wars in machete order",
                    Description    = "Next time you want to introduce someone to Star Wars for the first time, watch the films with them in this order: IV, V, II, III, VI.",
                    Privacy        = TraktAccessScope.Public,
                    DisplayNumbers = true,
                    AllowComments  = true,
                    SortBy         = "rank",
                    SortHow        = "asc",
                    CreatedAt      = CREATED_UPDATED_AT,
                    UpdatedAt      = CREATED_UPDATED_AT,
                    ItemCount      = 5,
                    CommentCount   = 1,
                    Likes          = 2,
                    Ids            = new TraktListIds
                    {
                        Trakt = 55,
                        Slug  = "star-wars-in-machete-order"
                    },
                    User = new TraktUser
                    {
                        Username  = "******",
                        IsPrivate = false,
                        Name      = "Sean Rudford",
                        IsVIP     = true,
                        IsVIP_EP  = true,
                        Ids       = new TraktUserIds
                        {
                            Slug = "sean"
                        }
                    }
                }
            };

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

                json.Should().Be(@"{""list"":{""name"":""Star Wars in machete order""," +
                                 @"""description"":""Next time you want to introduce someone to Star Wars for the first time, watch the films with them in this order: IV, V, II, III, VI.""," +
                                 @"""privacy"":""public"",""display_numbers"":true,""allow_comments"":true," +
                                 @"""sort_by"":""rank"",""sort_how"":""asc""," +
                                 $"\"created_at\":\"{CREATED_UPDATED_AT.ToTraktLongDateTimeString()}\"," +
                                 $"\"updated_at\":\"{CREATED_UPDATED_AT.ToTraktLongDateTimeString()}\"," +
                                 @"""item_count"":5,""comment_count"":1,""likes"":2," +
                                 @"""ids"":{""trakt"":55,""slug"":""star-wars-in-machete-order""}," +
                                 @"""user"":{""username"":""sean"",""private"":false," +
                                 @"""ids"":{""slug"":""sean""},""name"":""Sean Rudford""," +
                                 @"""vip"":true,""vip_ep"":true}}}");
            }
        }
        public async Task Test_CommentObjectJsonWriter_WriteObject_StringWriter_Only_UpdatedAt_Property()
        {
            ITraktComment traktComment = new TraktComment
            {
                UpdatedAt = CREATED_UPDATED_AT
            };

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

                json.Should().Be(@"{""id"":0,""created_at"":""0001-01-01T00:00:00.000Z""," +
                                 $"\"updated_at\":\"{CREATED_UPDATED_AT.ToTraktLongDateTimeString()}\"," +
                                 @"""spoiler"":false,""review"":false}");
            }
        }
コード例 #3
0
        public async Task Test_CommentArrayJsonWriter_WriteArray_StringWriter_SingleObject()
        {
            IEnumerable <ITraktComment> traktComments = new List <ITraktComment>
            {
                new TraktComment
                {
                    Id         = 76957U,
                    ParentId   = 1234U,
                    CreatedAt  = CREATED_UPDATED_AT,
                    UpdatedAt  = CREATED_UPDATED_AT,
                    Comment    = "I hate they made The flash a kids show. Could else be much better. And with a better flash offcourse.",
                    Spoiler    = true,
                    Review     = true,
                    Replies    = 1,
                    Likes      = 2,
                    UserRating = 7.3f,
                    User       = new TraktUser
                    {
                        Username  = "******",
                        IsPrivate = false,
                        Name      = "Sean Rudford",
                        IsVIP     = true,
                        IsVIP_EP  = true,
                        Ids       = new TraktUserIds
                        {
                            Slug = "sean"
                        }
                    }
                }
            };

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

                json.Should().Be(@"[{""id"":76957,""parent_id"":1234," +
                                 $"\"created_at\":\"{CREATED_UPDATED_AT.ToTraktLongDateTimeString()}\"," +
                                 $"\"updated_at\":\"{CREATED_UPDATED_AT.ToTraktLongDateTimeString()}\"," +
                                 @"""comment"":""I hate they made The flash a kids show. Could else be much better. And with a better flash offcourse.""," +
                                 @"""spoiler"":true,""review"":true,""replies"":1,""likes"":2,""user_rating"":7.3," +
                                 @"""user"":{""username"":""sean"",""private"":false,""ids"":{""slug"":""sean""}," +
                                 @"""name"":""Sean Rudford"",""vip"":true,""vip_ep"":true}}]");
            }
        }
コード例 #4
0
        public async Task Test_CommentItemArrayJsonWriter_WriteArray_StringWriter_SingleObject()
        {
            IEnumerable <ITraktCommentItem> traktCommentItems = new List <ITraktCommentItem>
            {
                new TraktCommentItem
                {
                    Type  = TraktObjectType.Movie,
                    Movie = new TraktMovie
                    {
                        Title = "Star Wars: The Force Awakens",
                        Year  = 2015,
                        Ids   = new TraktMovieIds
                        {
                            Trakt = 94024,
                            Slug  = "star-wars-the-force-awakens-2015",
                            Imdb  = "tt2488496",
                            Tmdb  = 140607
                        }
                    },
                    Show = new TraktShow
                    {
                        Title = "Game of Thrones",
                        Year  = 2011,
                        Ids   = new TraktShowIds
                        {
                            Trakt  = 1390,
                            Slug   = "game-of-thrones",
                            Tvdb   = 121361,
                            Imdb   = "tt0944947",
                            Tmdb   = 1399,
                            TvRage = 24493
                        }
                    },
                    Season = new TraktSeason
                    {
                        Number = 1,
                        Ids    = new TraktSeasonIds
                        {
                            Trakt  = 61430,
                            Tvdb   = 279121,
                            Tmdb   = 60523,
                            TvRage = 36939
                        }
                    },
                    Episode = new TraktEpisode
                    {
                        SeasonNumber = 1,
                        Number       = 1,
                        Title        = "Winter Is Coming",
                        Ids          = new TraktEpisodeIds
                        {
                            Trakt  = 73640,
                            Tvdb   = 3254641,
                            Imdb   = "tt1480055",
                            Tmdb   = 63056,
                            TvRage = 1065008299
                        }
                    },
                    List = new TraktList
                    {
                        Name           = "Star Wars in machete order",
                        Description    = "Next time you want to introduce someone to Star Wars for the first time, watch the films with them in this order: IV, V, II, III, VI.",
                        Privacy        = TraktAccessScope.Public,
                        DisplayNumbers = true,
                        AllowComments  = true,
                        SortBy         = "rank",
                        SortHow        = "asc",
                        CreatedAt      = CREATED_UPDATED_AT,
                        UpdatedAt      = CREATED_UPDATED_AT,
                        ItemCount      = 5,
                        CommentCount   = 1,
                        Likes          = 2,
                        Ids            = new TraktListIds
                        {
                            Trakt = 55,
                            Slug  = "star-wars-in-machete-order"
                        },
                        User = new TraktUser
                        {
                            Username  = "******",
                            IsPrivate = false,
                            Name      = "Sean Rudford",
                            IsVIP     = true,
                            IsVIP_EP  = true,
                            Ids       = new TraktUserIds
                            {
                                Slug = "sean"
                            }
                        }
                    }
                }
            };

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

                json.Should().Be(@"[{""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}}," +
                                 @"""show"":{""title"":""Game of Thrones"",""year"":2011," +
                                 @"""ids"":{""trakt"":1390,""slug"":""game-of-thrones""," +
                                 @"""tvdb"":121361,""imdb"":""tt0944947"",""tmdb"":1399,""tvrage"":24493}}," +
                                 @"""season"":{""number"":1,""ids"":{" +
                                 @"""trakt"":61430,""tvdb"":279121,""tmdb"":60523,""tvrage"":36939}}," +
                                 @"""episode"":{""season"":1,""number"":1," +
                                 @"""title"":""Winter Is Coming"",""ids"":{" +
                                 @"""trakt"":73640,""tvdb"":3254641,""imdb"":""tt1480055""," +
                                 @"""tmdb"":63056,""tvrage"":1065008299}}," +
                                 @"""list"":{""name"":""Star Wars in machete order""," +
                                 @"""description"":""Next time you want to introduce someone to Star Wars for the first time, watch the films with them in this order: IV, V, II, III, VI.""," +
                                 @"""privacy"":""public"",""display_numbers"":true,""allow_comments"":true," +
                                 @"""sort_by"":""rank"",""sort_how"":""asc""," +
                                 $"\"created_at\":\"{CREATED_UPDATED_AT.ToTraktLongDateTimeString()}\"," +
                                 $"\"updated_at\":\"{CREATED_UPDATED_AT.ToTraktLongDateTimeString()}\"," +
                                 @"""item_count"":5,""comment_count"":1,""likes"":2," +
                                 @"""ids"":{""trakt"":55,""slug"":""star-wars-in-machete-order""}," +
                                 @"""user"":{""username"":""sean"",""private"":false," +
                                 @"""ids"":{""slug"":""sean""},""name"":""Sean Rudford""," +
                                 @"""vip"":true,""vip_ep"":true}}}]");
            }
        }