public async Task GetRfiAttachments() { IPlanGridApi client = PlanGridClient.Create(); Page <Attachment> attachments = await client.GetRfiAttachments(TestData.Project1Uid, TestData.Project1Rfi1Uid); Assert.AreEqual(1, attachments.TotalCount); Assert.AreEqual("PA1.11.pdf", attachments.Data[0].Name); }
public async Task ReferenceAttachment() { IPlanGridApi client = PlanGridClient.Create(); var rfiInsert = new RfiUpsert { Question = "test question", Answer = "test answer", AssignedTo = new[] { TestData.ApiTestsUserUid }, DueAt = new DateTime(2020, 1, 1), IsLocked = false, SentAt = new DateTime(2019, 1, 1), StatusUid = TestData.Project2DraftRfiStatusUid, Title = "test title" }; Rfi rfi = await client.CreateRfi(TestData.Project2Uid, rfiInsert); FileUpload request = await client.CreateAttachmentUploadRequest(TestData.Project2Uid, new AttachmentUpload { ContentType = AttachmentUpload.Pdf, Name = "test name", Folder = "test folder" }); Stream payload = typeof(AttachmentTests).Assembly.GetManifestResourceStream("PlanGrid.Api.Tests.TestData.Sample.pdf"); Attachment attachment = await client.Upload <Attachment>(request, payload); await client.ReferenceAttachmentFromRfi(TestData.Project2Uid, rfi.Uid, new AttachmentReference { AttachmentUid = attachment.Uid }); Page <Attachment> attachments = await client.GetRfiAttachments(TestData.Project2Uid, rfi.Uid); Attachment rfiAttachment = attachments.Data.Single(); Assert.AreEqual(attachment.Uid, rfiAttachment.Uid); await client.RemoveAttachmentFromRfi(TestData.Project2Uid, rfi.Uid, rfiAttachment.Uid); attachments = await client.GetRfiAttachments(TestData.Project2Uid, rfi.Uid); Assert.AreEqual(0, attachments.Data.Length); }