|
| 1 | +namespace TraktNet.Tests.Objects.Basic.Implementations |
| 2 | +{ |
| 3 | + using FluentAssertions; |
| 4 | + using System; |
| 5 | + using System.Threading.Tasks; |
| 6 | + using Traits; |
| 7 | + using TraktNet.Enums; |
| 8 | + using TraktNet.Objects.Basic; |
| 9 | + using TraktNet.Objects.Basic.Json.Reader; |
| 10 | + using Xunit; |
| 11 | + |
| 12 | + [Category("Objects.Basic.Implementations")] |
| 13 | + public class TraktCommentItem_Tests |
| 14 | + { |
| 15 | + [Fact] |
| 16 | + public void Test_TraktCommentItem_Default_Constructor() |
| 17 | + { |
| 18 | + var traktCommentItem = new TraktCommentItem(); |
| 19 | + |
| 20 | + traktCommentItem.Type.Should().BeNull(); |
| 21 | + traktCommentItem.Movie.Should().BeNull(); |
| 22 | + traktCommentItem.Show.Should().BeNull(); |
| 23 | + traktCommentItem.Season.Should().BeNull(); |
| 24 | + traktCommentItem.Episode.Should().BeNull(); |
| 25 | + traktCommentItem.List.Should().BeNull(); |
| 26 | + } |
| 27 | + |
| 28 | + [Fact] |
| 29 | + public async Task Test_TraktCommentItem_From_Json() |
| 30 | + { |
| 31 | + var jsonReader = new CommentItemObjectJsonReader(); |
| 32 | + var traktCommentItem = await jsonReader.ReadObjectAsync(JSON) as TraktCommentItem; |
| 33 | + |
| 34 | + traktCommentItem.Should().NotBeNull(); |
| 35 | + traktCommentItem.Type.Should().Be(TraktObjectType.Movie); |
| 36 | + |
| 37 | + traktCommentItem.Movie.Should().NotBeNull(); |
| 38 | + traktCommentItem.Movie.Title.Should().Be("Star Wars: The Force Awakens"); |
| 39 | + traktCommentItem.Movie.Year.Should().Be(2015); |
| 40 | + traktCommentItem.Movie.Ids.Should().NotBeNull(); |
| 41 | + traktCommentItem.Movie.Ids.Trakt.Should().Be(94024U); |
| 42 | + traktCommentItem.Movie.Ids.Slug.Should().Be("star-wars-the-force-awakens-2015"); |
| 43 | + traktCommentItem.Movie.Ids.Imdb.Should().Be("tt2488496"); |
| 44 | + traktCommentItem.Movie.Ids.Tmdb.Should().Be(140607U); |
| 45 | + |
| 46 | + traktCommentItem.Show.Should().NotBeNull(); |
| 47 | + traktCommentItem.Show.Title.Should().Be("Game of Thrones"); |
| 48 | + traktCommentItem.Show.Year.Should().Be(2011); |
| 49 | + traktCommentItem.Show.Ids.Should().NotBeNull(); |
| 50 | + traktCommentItem.Show.Ids.Trakt.Should().Be(1390U); |
| 51 | + traktCommentItem.Show.Ids.Slug.Should().Be("game-of-thrones"); |
| 52 | + traktCommentItem.Show.Ids.Tvdb.Should().Be(121361U); |
| 53 | + traktCommentItem.Show.Ids.Imdb.Should().Be("tt0944947"); |
| 54 | + traktCommentItem.Show.Ids.Tmdb.Should().Be(1399U); |
| 55 | + traktCommentItem.Show.Ids.TvRage.Should().Be(24493U); |
| 56 | + |
| 57 | + traktCommentItem.Season.Should().NotBeNull(); |
| 58 | + traktCommentItem.Season.Number.Should().Be(1); |
| 59 | + traktCommentItem.Season.Ids.Should().NotBeNull(); |
| 60 | + traktCommentItem.Season.Ids.Trakt.Should().Be(61430U); |
| 61 | + traktCommentItem.Season.Ids.Tvdb.Should().Be(279121U); |
| 62 | + traktCommentItem.Season.Ids.Tmdb.Should().Be(60523U); |
| 63 | + traktCommentItem.Season.Ids.TvRage.Should().Be(36939U); |
| 64 | + |
| 65 | + traktCommentItem.Episode.Should().NotBeNull(); |
| 66 | + traktCommentItem.Episode.SeasonNumber.Should().Be(1); |
| 67 | + traktCommentItem.Episode.Number.Should().Be(1); |
| 68 | + traktCommentItem.Episode.Title.Should().Be("Winter Is Coming"); |
| 69 | + traktCommentItem.Episode.Ids.Should().NotBeNull(); |
| 70 | + traktCommentItem.Episode.Ids.Trakt.Should().Be(73640U); |
| 71 | + traktCommentItem.Episode.Ids.Tvdb.Should().Be(3254641U); |
| 72 | + traktCommentItem.Episode.Ids.Imdb.Should().Be("tt1480055"); |
| 73 | + traktCommentItem.Episode.Ids.Tmdb.Should().Be(63056U); |
| 74 | + traktCommentItem.Episode.Ids.TvRage.Should().Be(1065008299U); |
| 75 | + |
| 76 | + traktCommentItem.List.Should().NotBeNull(); |
| 77 | + traktCommentItem.List.Name.Should().Be("Star Wars in machete order"); |
| 78 | + traktCommentItem.List.Description.Should().Be("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."); |
| 79 | + traktCommentItem.List.Privacy.Should().Be(TraktAccessScope.Public); |
| 80 | + traktCommentItem.List.DisplayNumbers.Should().BeTrue(); |
| 81 | + traktCommentItem.List.AllowComments.Should().BeFalse(); |
| 82 | + traktCommentItem.List.SortBy.Should().Be("rank"); |
| 83 | + traktCommentItem.List.SortHow.Should().Be("asc"); |
| 84 | + traktCommentItem.List.CreatedAt.Should().Be(DateTime.Parse("2014-10-11T17:00:54.000Z").ToUniversalTime()); |
| 85 | + traktCommentItem.List.UpdatedAt.Should().Be(DateTime.Parse("2014-11-09T17:00:54.000Z").ToUniversalTime()); |
| 86 | + traktCommentItem.List.ItemCount.Should().Be(5); |
| 87 | + traktCommentItem.List.CommentCount.Should().Be(1); |
| 88 | + traktCommentItem.List.Likes.Should().Be(2); |
| 89 | + traktCommentItem.List.Ids.Should().NotBeNull(); |
| 90 | + traktCommentItem.List.Ids.Trakt.Should().Be(55U); |
| 91 | + traktCommentItem.List.Ids.Slug.Should().Be("star-wars-in-machete-order"); |
| 92 | + traktCommentItem.List.User.Should().NotBeNull(); |
| 93 | + traktCommentItem.List.User.Username.Should().Be("sean"); |
| 94 | + traktCommentItem.List.User.IsPrivate.Should().BeFalse(); |
| 95 | + traktCommentItem.List.User.Name.Should().Be("Sean Rudford"); |
| 96 | + traktCommentItem.List.User.IsVIP.Should().BeTrue(); |
| 97 | + traktCommentItem.List.User.IsVIP_EP.Should().BeFalse(); |
| 98 | + traktCommentItem.List.User.Ids.Should().NotBeNull(); |
| 99 | + traktCommentItem.List.User.Ids.Slug.Should().Be("sean"); |
| 100 | + } |
| 101 | + |
| 102 | + private const string JSON = |
| 103 | + @"{ |
| 104 | + ""type"": ""movie"", |
| 105 | + ""movie"": { |
| 106 | + ""title"": ""Star Wars: The Force Awakens"", |
| 107 | + ""year"": 2015, |
| 108 | + ""ids"": { |
| 109 | + ""trakt"": 94024, |
| 110 | + ""slug"": ""star-wars-the-force-awakens-2015"", |
| 111 | + ""imdb"": ""tt2488496"", |
| 112 | + ""tmdb"": 140607 |
| 113 | + } |
| 114 | + }, |
| 115 | + ""show"": { |
| 116 | + ""title"": ""Game of Thrones"", |
| 117 | + ""year"": 2011, |
| 118 | + ""ids"": { |
| 119 | + ""trakt"": 1390, |
| 120 | + ""slug"": ""game-of-thrones"", |
| 121 | + ""tvdb"": 121361, |
| 122 | + ""imdb"": ""tt0944947"", |
| 123 | + ""tmdb"": 1399, |
| 124 | + ""tvrage"": 24493 |
| 125 | + } |
| 126 | + }, |
| 127 | + ""season"": { |
| 128 | + ""number"": 1, |
| 129 | + ""ids"": { |
| 130 | + ""trakt"": 61430, |
| 131 | + ""tvdb"": 279121, |
| 132 | + ""tmdb"": 60523, |
| 133 | + ""tvrage"": 36939 |
| 134 | + } |
| 135 | + }, |
| 136 | + ""episode"": { |
| 137 | + ""season"": 1, |
| 138 | + ""number"": 1, |
| 139 | + ""title"": ""Winter Is Coming"", |
| 140 | + ""ids"": { |
| 141 | + ""trakt"": 73640, |
| 142 | + ""tvdb"": 3254641, |
| 143 | + ""imdb"": ""tt1480055"", |
| 144 | + ""tmdb"": 63056, |
| 145 | + ""tvrage"": 1065008299 |
| 146 | + } |
| 147 | + }, |
| 148 | + ""list"": { |
| 149 | + ""name"": ""Star Wars in machete order"", |
| 150 | + ""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."", |
| 151 | + ""privacy"": ""public"", |
| 152 | + ""display_numbers"": true, |
| 153 | + ""allow_comments"": false, |
| 154 | + ""sort_by"": ""rank"", |
| 155 | + ""sort_how"": ""asc"", |
| 156 | + ""created_at"": ""2014-10-11T17:00:54.000Z"", |
| 157 | + ""updated_at"": ""2014-11-09T17:00:54.000Z"", |
| 158 | + ""item_count"": 5, |
| 159 | + ""comment_count"": 1, |
| 160 | + ""likes"": 2, |
| 161 | + ""ids"": { |
| 162 | + ""trakt"": 55, |
| 163 | + ""slug"": ""star-wars-in-machete-order"" |
| 164 | + }, |
| 165 | + ""user"": { |
| 166 | + ""username"": ""sean"", |
| 167 | + ""private"": false, |
| 168 | + ""name"": ""Sean Rudford"", |
| 169 | + ""vip"": true, |
| 170 | + ""vip_ep"": false, |
| 171 | + ""ids"": { |
| 172 | + ""slug"": ""sean"" |
| 173 | + } |
| 174 | + } |
| 175 | + } |
| 176 | + }"; |
| 177 | + } |
| 178 | +} |
0 commit comments