public async Task Test_TraktUsersModule_CreateCustomList_With_Description_And_Privacy_And_AllowComments() { ITraktUserCustomListPost createListPost = new TraktUserCustomListPost { Name = LIST_NAME, Description = DESCRIPTION, Privacy = PRIVACY, AllowComments = ALLOW_COMMENTS }; string postJson = await TestUtility.SerializeObject(createListPost); postJson.Should().NotBeNullOrEmpty(); TraktClient client = TestUtility.GetOAuthMockClient(CREATE_CUSTOM_LIST_URI, postJson, LIST_JSON); TraktResponse <ITraktList> response = await client.Users.CreateCustomListAsync(USERNAME, LIST_NAME, DESCRIPTION, PRIVACY, null, ALLOW_COMMENTS); response.Should().NotBeNull(); response.IsSuccess.Should().BeTrue(); response.HasValue.Should().BeTrue(); response.Value.Should().NotBeNull(); ITraktList responseValue = response.Value; responseValue.Name.Should().Be("Star Wars in machete order"); responseValue.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."); responseValue.Privacy.Should().Be(TraktAccessScope.Public); responseValue.DisplayNumbers.Should().BeTrue(); responseValue.AllowComments.Should().BeFalse(); responseValue.SortBy.Should().Be("rank"); responseValue.SortHow.Should().Be("asc"); responseValue.CreatedAt.Should().Be(DateTime.Parse("2014-10-11T17:00:54.000Z").ToUniversalTime()); responseValue.UpdatedAt.Should().Be(DateTime.Parse("2014-11-09T17:00:54.000Z").ToUniversalTime()); responseValue.ItemCount.Should().Be(5); responseValue.CommentCount.Should().Be(1); responseValue.Likes.Should().Be(2); responseValue.Ids.Should().NotBeNull(); responseValue.Ids.Trakt.Should().Be(55); responseValue.Ids.Slug.Should().Be("star-wars-in-machete-order"); responseValue.User.Should().NotBeNull(); }
/// <summary> /// Posts a comment for the given <see cref="ITraktList" />. /// <para>OAuth authorization required.</para> /// <para> /// See <a href="http://docs.trakt.apiary.io/#reference/comments/comments/post-a-comment">"Trakt API Doc - Comments: Comments"</a> for more information. /// </para> /// </summary> /// <param name="list">The <see cref="ITraktList" />, for which the comment should be posted.</param> /// <param name="comment">The comment's content for the given list. Should be at least five words long.</param> /// <param name="containsSpoiler">Determines, if the <paramref name="comment" /> contains any spoilers.</param> /// <param name="sharing"><see cref="ITraktSharing" /> instance, containing sharing information for the comment.</param> /// <param name="cancellationToken"></param> /// <returns>An <see cref="ITraktCommentPostResponse" /> instance, containing the successfully posted comment's data.</returns> /// <exception cref="TraktException">Thrown, if the request fails.</exception> /// <exception cref="ArgumentException"> /// Thrown, if the given list has no valid ids. See also <seealso cref="ITraktListIds" />. /// Thrown, if the given comment is null or empty. /// </exception> /// <exception cref="ArgumentNullException">Thrown, if the given list is null or its ids are null.</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown, if the given comment's word count is below five.</exception> public Task <TraktResponse <ITraktCommentPostResponse> > PostListCommentAsync(ITraktList list, string comment, bool?containsSpoiler = null, ITraktSharing sharing = null, CancellationToken cancellationToken = default) { ValidateList(list); ValidateComment(comment); var requestHandler = new RequestHandler(Client); return(requestHandler.ExecuteSingleItemRequestAsync(new CommentPostRequest <ITraktListCommentPost> { RequestBody = new TraktListCommentPost { List = new TraktList { Ids = list.Ids }, Comment = comment, Spoiler = containsSpoiler, Sharing = sharing } }, cancellationToken)); }