public void TestTraktCommentUpdatePostDefaultConstructor()
        {
            var commentUpdate = new TraktCommentUpdatePost();

            commentUpdate.Comment.Should().BeNullOrEmpty();
            commentUpdate.Spoiler.Should().NotHaveValue();
        }
        public async Task Test_TraktCommentsModule_UpdateComment_ArgumentExceptions()
        {
            ITraktCommentUpdatePost commentUpdatePost = new TraktCommentUpdatePost
            {
                Comment = COMMENT_TEXT
            };

            string postJson = await TestUtility.SerializeObject(commentUpdatePost);

            postJson.Should().NotBeNullOrEmpty();

            TraktClient client = TestUtility.GetOAuthMockClient(UPDATE_COMMENT_URI, postJson, COMMENT_POST_RESPONSE_JSON);

            Func <Task <TraktResponse <ITraktCommentPostResponse> > > act = () => client.Comments.UpdateCommentAsync(0, COMMENT_TEXT);

            act.Should().Throw <ArgumentException>();

            act = () => client.Comments.UpdateCommentAsync(COMMENT_ID, null);
            act.Should().Throw <ArgumentException>();

            act = () => client.Comments.UpdateCommentAsync(COMMENT_ID, string.Empty);
            act.Should().Throw <ArgumentException>();

            const string comment = "one two three four";

            act = () => client.Comments.UpdateCommentAsync(COMMENT_ID, comment);
            act.Should().Throw <ArgumentOutOfRangeException>();
        }
        public override async Task <ITraktCommentUpdatePost> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktCommentUpdatePost)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktCommentUpdatePost commentUpdatePost = new TraktCommentUpdatePost();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.COMMENT_UPDATE_POST_PROPERTY_NAME_COMMENT:
                        commentUpdatePost.Comment = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.COMMENT_UPDATE_POST_PROPERTY_NAME_SPOILER:
                    {
                        bool?value = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        if (value.HasValue)
                        {
                            commentUpdatePost.Spoiler = value.Value;
                        }

                        break;
                    }

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(commentUpdatePost);
            }

            return(await Task.FromResult(default(ITraktCommentUpdatePost)));
        }
        public void TestTraktCommentUpdatePostWriteJson()
        {
            var comment = "this is a comment";
            var spoiler = true;

            var commentUpdate = new TraktCommentUpdatePost {
                Comment = comment, Spoiler = spoiler
            };

            var strJson = JsonConvert.SerializeObject(commentUpdate);

            strJson.Should().NotBeNullOrEmpty();

            var commentUpdateFromJson = JsonConvert.DeserializeObject <TraktCommentUpdatePost>(strJson);

            commentUpdateFromJson.Should().NotBeNull();
            commentUpdateFromJson.Comment.Should().Be(comment);
            commentUpdateFromJson.Spoiler.Should().Be(spoiler);
        }
        public async Task Test_TraktCommentsModule_UpdateComment_With_Spoiler()
        {
            ITraktCommentUpdatePost commentUpdatePost = new TraktCommentUpdatePost
            {
                Comment = COMMENT_TEXT,
                Spoiler = SPOILER
            };

            string postJson = await TestUtility.SerializeObject(commentUpdatePost);

            postJson.Should().NotBeNullOrEmpty();

            TraktClient client = TestUtility.GetOAuthMockClient(UPDATE_COMMENT_URI, postJson, COMMENT_POST_RESPONSE_JSON);
            TraktResponse <ITraktCommentPostResponse> response = await client.Comments.UpdateCommentAsync(COMMENT_ID, COMMENT_TEXT, SPOILER);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull();

            ITraktCommentPostResponse responseValue = response.Value;

            responseValue.Id.Should().Be(COMMENT_ID);
            responseValue.ParentId.Should().Be(0U);
            responseValue.CreatedAt.Should().Be(DateTime.Parse("2014-08-04T06:46:01.996Z").ToUniversalTime());
            responseValue.Comment.Should().Be("Oh, I wasn't really listening.");
            responseValue.Spoiler.Should().BeFalse();
            responseValue.Review.Should().BeFalse();
            responseValue.Replies.Should().Be(0);
            responseValue.Likes.Should().Be(0);
            responseValue.UserRating.Should().NotHaveValue();
            responseValue.User.Should().NotBeNull();
            responseValue.User.Username.Should().Be("sean");
            responseValue.User.IsPrivate.Should().BeFalse();
            responseValue.User.Name.Should().Be("Sean Rudford");
            responseValue.User.IsVIP.Should().BeTrue();
            responseValue.User.IsVIP_EP.Should().BeFalse();
            responseValue.Sharing.Should().NotBeNull();
            responseValue.Sharing.Facebook.Should().BeTrue();
            responseValue.Sharing.Twitter.Should().BeTrue();
            responseValue.Sharing.Tumblr.Should().BeFalse();
            responseValue.Sharing.Medium.Should().BeTrue();
        }