예제 #1
0
        public virtual void TestAddComment()
        {
            Comment comment = new Comment.AddCommentBuilder("This is a new comment.").Build();

            server.setResponseBody("../../../TestSDK/resources/addComment.json");
            comment = commentResources.AddComment(8357140688594820, 5773448686397316, comment);

            Assert.IsTrue(comment.CreatedBy.Email == "*****@*****.**");
            Assert.IsTrue(comment.Id == 6834973207488388);
            Assert.IsTrue(comment.Text == "This is a new comment.");
        }
예제 #2
0
        private static long CreateDiscussion(SmartsheetClient smartsheet, long sheetId)
        {
            Comment    commentToAdd = new Comment.AddCommentBuilder("this is a comment").Build();
            Discussion discussion   = smartsheet.SheetResources.DiscussionResources.CreateDiscussion(sheetId, new Discussion.CreateDiscussionBuilder("a discussion", commentToAdd).Build());

            Discussion discussion2 = smartsheet.SheetResources.DiscussionResources.CreateDiscussionWithAttachment(sheetId, new Discussion.CreateDiscussionBuilder("a discussion", commentToAdd).Build(), path, null);

            Assert.IsTrue(discussion2.Comments[0].Attachments[0].Name == "TestFile.txt");

            long discussionId = discussion.Id.Value;

            return(discussionId);
        }
예제 #3
0
        public void TestDiscussionResources()
        {
            SmartsheetClient smartsheet = new SmartsheetBuilder().SetMaxRetryTimeout(30000).Build();

            long sheetId = CreateSheet(smartsheet);

            Discussion discussionToCreate  = new Discussion.CreateDiscussionBuilder("A discussion", new Comment.AddCommentBuilder("a comment").Build()).Build();
            Discussion createdDiscussion   = smartsheet.SheetResources.DiscussionResources.CreateDiscussion(sheetId, discussionToCreate);
            long       createdDiscussionId = createdDiscussion.Id.Value;
            string     path = "../../../IntegrationTestSDK/TestFile.txt";
            Discussion createdDiscussionWithFile = smartsheet.SheetResources.DiscussionResources.CreateDiscussionWithAttachment(sheetId, discussionToCreate, path, null);

            Assert.IsTrue(createdDiscussionWithFile.Comments[0].Attachments[0].Name == "TestFile.txt");


            PaginatedResult <Discussion> discussions = smartsheet.SheetResources.DiscussionResources.ListDiscussions(sheetId, new DiscussionInclusion[] { DiscussionInclusion.COMMENTS, DiscussionInclusion.ATTACHMENTS }, null);

            Assert.IsTrue(discussions.TotalCount == 2);
            Assert.IsTrue(discussions.Data.Count == 2);
            Assert.IsTrue(discussions.Data[0].Id.Value == createdDiscussion.Id.Value || discussions.Data[0].Id.Value == createdDiscussionWithFile.Id.Value);
            Assert.IsTrue(discussions.Data[1].Id.Value == createdDiscussion.Id.Value || discussions.Data[1].Id.Value == createdDiscussionWithFile.Id.Value);


            Discussion getDiscussionWithFile = smartsheet.SheetResources.DiscussionResources.GetDiscussion(sheetId, createdDiscussionWithFile.Id.Value);

            Assert.IsTrue(getDiscussionWithFile.Title == "A discussion");
            Assert.IsTrue(getDiscussionWithFile.Comments.Count == 1);
            Assert.IsTrue(getDiscussionWithFile.Comments[0].Attachments.Count == 1);
            Assert.IsTrue(getDiscussionWithFile.Comments[0].Attachments[0].Name == "TestFile.txt");

            Row         row  = new Row.AddRowBuilder(true, null, null, null, null).Build();
            IList <Row> rows = smartsheet.SheetResources.RowResources.AddRows(sheetId, new Row[] { row });

            Assert.IsTrue(rows.Count == 1);
            Assert.IsTrue(rows[0].Id.HasValue);
            long       rowId   = rows[0].Id.Value;
            Comment    comment = new Comment.AddCommentBuilder("a comment!").Build();
            Discussion discussionToCreateOnRow            = new Discussion.CreateDiscussionBuilder("discussion on row", comment).Build();
            Discussion discussionCreatedOnRow             = smartsheet.SheetResources.RowResources.DiscussionResources.CreateDiscussionWithAttachment(sheetId, rowId, discussionToCreateOnRow, path, null);
            PaginatedResult <Discussion> discussionsOnRow = smartsheet.SheetResources.RowResources.DiscussionResources
                                                            .ListDiscussions(sheetId, rowId, new DiscussionInclusion[] { DiscussionInclusion.COMMENTS }, null);

            Assert.IsTrue(discussionsOnRow.Data.Count == 1);
            Assert.IsTrue(discussionsOnRow.Data[0].Title == "discussion on row");
            Assert.IsTrue(discussionsOnRow.Data[0].Comments[0].Text == "discussion on row\n\na comment!");

            smartsheet.SheetResources.DeleteSheet(sheetId);
        }
예제 #4
0
        public virtual void TestAddCommentWithAttachment()
        {
            string  file    = @"..\..\..\TestSDK\resources\wordFile.docx";
            Comment comment = new Comment.AddCommentBuilder("Please review the attached file.").Build();

            server.setResponseBody("../../../TestSDK/resources/addCommentWithAttachment.json");
            Comment newComment = commentResources.AddCommentWithAttachment(8357140688594820, 5773448686397316, comment, file, "application/msword");

            Assert.IsTrue(newComment.Id == 2570595675203460);
            Assert.IsTrue(newComment.CreatedBy.Name == "Eric Yan");
            Assert.IsTrue(newComment.Attachments[0].Id == 6130526026262404);
            Assert.IsTrue(newComment.Attachments[0].Name == "wordFile.docx");
            Assert.IsTrue(newComment.Attachments[0].AttachmentType == AttachmentType.FILE);
            Assert.IsTrue(newComment.Attachments[0].ParentId == 2570595675203460);

            //Will not be able to deserialize (wIll throw error) unless Attachment object is also updated.
            //Assset TO-DO
        }