From 2fadadfba791e3d355247d3ac5a35fa103db467d Mon Sep 17 00:00:00 2001 From: Justin Gilroy Date: Mon, 12 Feb 2024 09:01:24 -0800 Subject: [PATCH 1/3] fix: verify all attachments --- .../AttachmentResourcesTest.cs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/integration-test-sdk-net60/AttachmentResourcesTest.cs b/integration-test-sdk-net60/AttachmentResourcesTest.cs index 2a7345b1f..2c2b022c2 100644 --- a/integration-test-sdk-net60/AttachmentResourcesTest.cs +++ b/integration-test-sdk-net60/AttachmentResourcesTest.cs @@ -89,6 +89,7 @@ private long AttachFileAndUrlToSheet(SmartsheetClient smartsheet, long sheetId) Assert.IsTrue(attachment.AttachmentType == AttachmentType.FILE); Assert.IsTrue(attachment.Name == "TestFile.txt"); + VerifyAttachmentContent(smartsheet, sheetId, attachment); return attachment.Id.Value; } @@ -103,6 +104,8 @@ private long AttachFileAndUrlToRow(SmartsheetClient smartsheet, long sheetId) Assert.IsTrue(attachment.AttachmentType == AttachmentType.FILE); Assert.IsTrue(attachment.Name == "TestFile.txt"); + VerifyAttachmentContent(smartsheet, sheetId, attachment); + Attachment attachToResource = new Attachment.CreateAttachmentBuilder("http://www.bing.com", AttachmentType.LINK).Build(); attachment = smartsheet.SheetResources.RowResources.AttachmentResources.AttachUrl(sheetId, rowId, attachToResource); Assert.IsTrue(attachment.Url == "http://www.bing.com"); @@ -119,6 +122,17 @@ private long AttachFileAndUrlToComment(SmartsheetClient smartsheet, long sheetId Assert.IsTrue(attachment.AttachmentType == AttachmentType.FILE); Assert.IsTrue(attachment.Name == "TestFile.txt"); + VerifyAttachmentContent(smartsheet, sheetId, attachment); + + Attachment attachToResource = new Attachment.CreateAttachmentBuilder("http://www.google.com", AttachmentType.LINK).Build(); + attachment = smartsheet.SheetResources.CommentResources.AttachmentResources.AttachUrl(sheetId, commentId, attachToResource); + Assert.IsTrue(attachment.Url == "http://www.google.com"); + + return discussionCreated.Id.Value; + } + + private Attachment VerifyAttachmentContent(SmartsheetClient smartsheet, long sheetId, Attachment attachment) + { attachment = smartsheet.SheetResources.AttachmentResources.GetAttachment(sheetId, attachment.Id.Value); var request = new RestRequest(attachment.Url); @@ -128,12 +142,7 @@ private long AttachFileAndUrlToComment(SmartsheetClient smartsheet, long sheetId var fileContents = File.ReadAllText(path); Assert.AreEqual(attachmentContent, fileContents); - - Attachment attachToResource = new Attachment.CreateAttachmentBuilder("http://www.google.com", AttachmentType.LINK).Build(); - attachment = smartsheet.SheetResources.CommentResources.AttachmentResources.AttachUrl(sheetId, commentId, attachToResource); - Assert.IsTrue(attachment.Url == "http://www.google.com"); - - return discussionCreated.Id.Value; + return attachment; } private static long CreateSheet(SmartsheetClient smartsheet) From ff325d4563abf9c8d3610a4b7db94499009315c9 Mon Sep 17 00:00:00 2001 From: Justin Gilroy Date: Mon, 12 Feb 2024 09:38:08 -0800 Subject: [PATCH 2/3] fix: cleanup verify method --- integration-test-sdk-net60/AttachmentResourcesTest.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/integration-test-sdk-net60/AttachmentResourcesTest.cs b/integration-test-sdk-net60/AttachmentResourcesTest.cs index 2c2b022c2..df6bb9529 100644 --- a/integration-test-sdk-net60/AttachmentResourcesTest.cs +++ b/integration-test-sdk-net60/AttachmentResourcesTest.cs @@ -1,4 +1,4 @@ -using RestSharp; +using RestSharp; using Smartsheet.Api; using Smartsheet.Api.Models; @@ -131,7 +131,7 @@ private long AttachFileAndUrlToComment(SmartsheetClient smartsheet, long sheetId return discussionCreated.Id.Value; } - private Attachment VerifyAttachmentContent(SmartsheetClient smartsheet, long sheetId, Attachment attachment) + private void VerifyAttachmentContent(SmartsheetClient smartsheet, long sheetId, Attachment attachment) { attachment = smartsheet.SheetResources.AttachmentResources.GetAttachment(sheetId, attachment.Id.Value); @@ -141,8 +141,7 @@ private Attachment VerifyAttachmentContent(SmartsheetClient smartsheet, long she var fileContents = File.ReadAllText(path); - Assert.AreEqual(attachmentContent, fileContents); - return attachment; + Assert.AreEqual(fileContents, attachmentContent); } private static long CreateSheet(SmartsheetClient smartsheet) From d79364079bebd0ddf2d3148968bc1cf9e26b7d6c Mon Sep 17 00:00:00 2001 From: Justin Gilroy Date: Mon, 12 Feb 2024 09:50:56 -0800 Subject: [PATCH 3/3] fix: relocate method definition --- .../AttachmentResourcesTest.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/integration-test-sdk-net60/AttachmentResourcesTest.cs b/integration-test-sdk-net60/AttachmentResourcesTest.cs index df6bb9529..99023dab9 100644 --- a/integration-test-sdk-net60/AttachmentResourcesTest.cs +++ b/integration-test-sdk-net60/AttachmentResourcesTest.cs @@ -131,19 +131,6 @@ private long AttachFileAndUrlToComment(SmartsheetClient smartsheet, long sheetId return discussionCreated.Id.Value; } - private void VerifyAttachmentContent(SmartsheetClient smartsheet, long sheetId, Attachment attachment) - { - attachment = smartsheet.SheetResources.AttachmentResources.GetAttachment(sheetId, attachment.Id.Value); - - var request = new RestRequest(attachment.Url); - - var attachmentContent = new RestClient(attachment.Url).Get(request).Content; - - var fileContents = File.ReadAllText(path); - - Assert.AreEqual(fileContents, attachmentContent); - } - private static long CreateSheet(SmartsheetClient smartsheet) { Column[] columnsToCreate = new Column[] { @@ -156,5 +143,18 @@ private static long CreateSheet(SmartsheetClient smartsheet) Assert.IsTrue(createdSheet.Columns[1].Title == "col 2"); return createdSheet.Id.Value; } + + private void VerifyAttachmentContent(SmartsheetClient smartsheet, long sheetId, Attachment attachment) + { + attachment = smartsheet.SheetResources.AttachmentResources.GetAttachment(sheetId, attachment.Id.Value); + + var request = new RestRequest(attachment.Url); + + var attachmentContent = new RestClient(attachment.Url).Get(request).Content; + + var fileContents = File.ReadAllText(path); + + Assert.AreEqual(fileContents, attachmentContent); + } } } \ No newline at end of file