public async Task ViewFileComments_ValidResponse_ValidFile() { /*** Arrange ***/ string responseString = "{ \"total_count\": 1, \"entries\": [ { \"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 <BoxCollection <BoxComment> >(It.IsAny <IBoxRequest>())) .Returns(Task.FromResult <IBoxResponse <BoxCollection <BoxComment> > >(new BoxResponse <BoxCollection <BoxComment> >() { Status = ResponseStatus.Success, ContentString = responseString })); /*** Act ***/ BoxCollection <BoxComment> c = await _filesManager.GetCommentsAsync("0"); BoxComment comment = c.Entries.FirstOrDefault(); /*** Assert ***/ Assert.AreEqual(1, c.TotalCount); Assert.AreEqual("191969", comment.Id); Assert.AreEqual(false, comment.IsReplyComment); Assert.AreEqual("These tigers are cool!", comment.Message); Assert.AreEqual("user", comment.CreatedBy.Type); Assert.AreEqual("17738362", comment.CreatedBy.Id); Assert.AreEqual("sean rose", comment.CreatedBy.Name); Assert.AreEqual("*****@*****.**", comment.CreatedBy.Login); }
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); }
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); }
protected virtual void PrintComment(BoxComment comment) { Reporter.WriteInformation($"Comment ID: {comment.Id}"); Reporter.WriteInformation($"Comment Message: {comment.Message}"); Reporter.WriteInformation($"Comment Created at: {comment.CreatedAt}"); Reporter.WriteInformation($"Comment Modified at: {comment.ModifiedAt}"); Reporter.WriteInformation($"Comment Tagged Message: {comment.TaggedMessage}"); Reporter.WriteInformation($"Is a reply?: {comment.IsReplyComment}"); Reporter.WriteInformation("Comment Created by:"); base.PrintMiniUser(comment.CreatedBy); Reporter.WriteInformation("Comment on item: "); base.PrintEntity(comment.Item); }
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); }
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"); }