A request class for making comment requests
        public async Task AddComment_ValidResponse_ValidComment()
        {
            /*** Arrange ***/
            string responseString = "{\"type\":\"comment\",\"id\":\"191969\",\"is_reply_comment\":false,\"message\":\"These tigers are cool!\",\"created_by\":{\"type\":\"user\",\"id\":\"17738362\",\"name\":\"sean rose\",\"login\":\"[email protected]\"},\"created_at\":\"2012-12-12T11:25:01-08:00\",\"item\":{\"id\":\"5000948880\",\"type\":\"file\"},\"modified_at\":\"2012-12-12T11:25:01-08:00\"}";
            _handler.Setup(h => h.ExecuteAsync<BoxComment>(It.IsAny<IBoxRequest>()))
                .Returns(Task.FromResult<IBoxResponse<BoxComment>>(new BoxResponse<BoxComment>()
                {
                    Status = ResponseStatus.Success,
                    ContentString = responseString
                }));

            /*** Act ***/
            BoxCommentRequest request = new BoxCommentRequest()
            {
                Item = new BoxRequestEntity()
                {
                    Id = "fakeId",
                    Type = BoxType.file
                },
                Message = "fake message"
            };
            BoxComment c = await _commentsManager.AddCommentAsync(request);

            /*** Assert ***/
            Assert.AreEqual("comment", c.Type);
            Assert.AreEqual("191969", c.Id);
            Assert.AreEqual("These tigers are cool!", c.Message);
        }
        public async Task CommentsWorkflow_LiveSession_ValidResponse()
        {

            // Test adding a new comment
            const string message = "this is a test";

            BoxCommentRequest addReq = new BoxCommentRequest()
            {
                Message = message,
                Item = new BoxRequestEntity()
                {
                    Id = fileId,
                    Type = BoxType.file
                }
            };
            
            BoxComment c = await _client.CommentsManager.AddCommentAsync(addReq);

            Assert.AreEqual(fileId, c.Item.Id);
            Assert.AreEqual(BoxType.file.ToString(), c.Item.Type);
            Assert.AreEqual(BoxType.comment.ToString(), c.Type);
            Assert.AreEqual(message, c.Message);


            // Test getting the comment information
            BoxComment cInfo = await _client.CommentsManager.GetInformationAsync(c.Id);

            Assert.AreEqual(c.Id, cInfo.Id);
            Assert.AreEqual(BoxType.comment.ToString(), cInfo.Type);


            // Test updating a message
            const string updateMessage = "this is an updated test comment";

            BoxCommentRequest updateReq = new BoxCommentRequest()
            {
                Message = updateMessage
            };

            BoxComment cUpdate = await _client.CommentsManager.UpdateAsync(c.Id, updateReq);

            Assert.AreEqual(c.Id, cUpdate.Id);
            Assert.AreEqual(BoxType.comment.ToString(), cUpdate.Type);
            Assert.AreEqual(updateMessage, cUpdate.Message);

            // Test deleting a comment
            bool success = await _client.CommentsManager.DeleteAsync(c.Id);

            Assert.AreEqual(true, success);
        }
        /// <summary>
        /// Used to update the message of the comment.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<BoxComment> UpdateAsync(string id, BoxCommentRequest commentsRequest, List<string> fields = null)
        {
            id.ThrowIfNullOrWhiteSpace("id");
            commentsRequest.ThrowIfNull("commentsRequest")
                .Message.ThrowIfNullOrWhiteSpace("commentsRequest.Message");

            BoxRequest request = new BoxRequest(_config.CommentsEndpointUri, id)
                .Method(RequestMethod.Put)
                .Param(ParamFields, fields)
                .Payload(_converter.Serialize(commentsRequest));

            IBoxResponse<BoxComment> response = await ToResponseAsync<BoxComment>(request).ConfigureAwait(false);

            return response.ResponseObject;
        }
        public async Task CommentsWorkflow_LiveSession_ValidResponse()
        {
            const string fileId = "16894947279";
            const string message = "this is a test Comment";

            BoxCommentRequest addReq = new BoxCommentRequest()
            {
                Message = message,
                Item = new BoxRequestEntity()
                {
                    Id = fileId,
                    Type = BoxType.file
                }
            };
            
            BoxComment c = await _client.CommentsManager.AddCommentAsync(addReq);

            Assert.AreEqual(fileId, c.Item.Id, "Comment was added to incorrect file");
            Assert.AreEqual(BoxType.file.ToString(), c.Item.Type, "Comment was not added to a file");
            Assert.AreEqual(BoxType.comment.ToString(), c.Type, "Returned object is not a comment");
            Assert.AreEqual(message, c.Message, "Wrong comment added to file");
            
            // Get comment details
            BoxComment cInfo = await _client.CommentsManager.GetInformationAsync(c.Id);

            Assert.AreEqual(c.Id, cInfo.Id, "two comment objects have different ids");
            Assert.AreEqual(BoxType.comment.ToString(), cInfo.Type, "returned object is not a comment");
            
            // Update the comment
            const string updateMessage = "this is an updated test comment";

            BoxCommentRequest updateReq = new BoxCommentRequest()
            {
                Message = updateMessage
            };

            BoxComment cUpdate = await _client.CommentsManager.UpdateAsync(c.Id, updateReq);

            Assert.AreEqual(c.Id, cUpdate.Id, "Wrong comment was updated");
            Assert.AreEqual(BoxType.comment.ToString(), cUpdate.Type, "returned type of update is not a comment");
            Assert.AreEqual(updateMessage, cUpdate.Message, "Comment was not updated with correct string");

            // Deleting a comment
            bool success = await _client.CommentsManager.DeleteAsync(c.Id);

            Assert.AreEqual(true, success, "Unsuccessful comment delete");
        }
        /// <summary>
        /// Used to add a comment by the user to a specific file, discussion, or comment (i.e. as a reply comment).
        /// </summary>
        /// <param name="commentRequest"></param>
        /// <returns></returns>
        public async Task<BoxComment> AddCommentAsync(BoxCommentRequest commentRequest, List<string> fields = null)
        {
            commentRequest.ThrowIfNull("commentRequest")
                .Item.ThrowIfNull("commentRequest.Item")
                .Id.ThrowIfNullOrWhiteSpace("commentRequest.Item.Id");
            if (commentRequest.Item.Type == null)
                throw new ArgumentNullException("commentRequest.Item.Type");

            BoxRequest request = new BoxRequest(_config.CommentsEndpointUri)
                .Method(RequestMethod.Post)
                .Param(ParamFields, fields)
                .Payload(_converter.Serialize(commentRequest));

            IBoxResponse<BoxComment> response = await ToResponseAsync<BoxComment>(request).ConfigureAwait(false);

            return response.ResponseObject;
        }
        public async Task UpdateComment_ValidResponse_ValidComment()
        {
            /*** Arrange ***/
            string responseString = "{\"type\":\"comment\",\"id\":\"191969\",\"is_reply_comment\":false,\"message\":\"These tigers are cool!\",\"created_by\":{\"type\":\"user\",\"id\":\"17738362\",\"name\":\"sean rose\",\"login\":\"[email protected]\"},\"created_at\":\"2012-12-12T11:25:01-08:00\",\"item\":{\"id\":\"5000948880\",\"type\":\"file\"},\"modified_at\":\"2012-12-12T11:25:01-08:00\"}";
            IBoxRequest boxRequest = null;
            _handler.Setup(h => h.ExecuteAsync<BoxComment>(It.IsAny<IBoxRequest>()))
                .Returns(Task.FromResult<IBoxResponse<BoxComment>>(new BoxResponse<BoxComment>()
                {
                    Status = ResponseStatus.Success,
                    ContentString = responseString
                })).Callback<IBoxRequest>(r => boxRequest = r);

            /*** Act ***/
            BoxCommentRequest request = new BoxCommentRequest()
            {
                Message = "fakeMessage"
            };

            BoxComment c = await _commentsManager.UpdateAsync("fakeId", request);

            /*** Assert ***/
            /*** Request ***/
            BoxCommentRequest payLoad = JsonConvert.DeserializeObject<BoxCommentRequest>(boxRequest.Payload);
            Assert.AreEqual(request.Message, payLoad.Message);
            /** Response ***/
            Assert.AreEqual("comment", c.Type);
            Assert.AreEqual("191969", c.Id);
            Assert.AreEqual("These tigers are cool!", c.Message);
        }