public async Task GetRfis() { IPlanGridApi client = PlanGridClient.Create(); Page <Rfi> rfis = await client.GetRfis(TestData.Project1Uid); Assert.AreEqual(1, rfis.TotalCount); Rfi rfi = rfis.Data[0]; await ValidateRfi(rfi, client); }
private async Task ValidateRfi(Rfi rfi, IPlanGridApi client) { Page <RfiChange> history = await client.GetRfiHistory(TestData.Project1Uid, rfi.Uid); Assert.AreEqual("locked", history.Data[0].Field); Assert.AreEqual(true, (bool)history.Data[0].NewValue); Assert.AreEqual(false, (bool)history.Data[0].OldValue); Assert.AreEqual("Test Rfi Answer", rfi.Answer); Assert.AreEqual("Test Rfi Question", rfi.Question); Assert.AreEqual("Test Rfi", rfi.Title); Assert.AreEqual(1, rfi.Number); Assert.AreEqual(DateTime.Parse("2015/11/18 19:30:21.000"), rfi.SentAt); Assert.AreEqual(DateTime.Parse("2015/11/19 19:30:13.000"), rfi.DueAt); Assert.AreEqual(DateTime.Parse("11/17/2015 20:06:48.115"), rfi.UpdatedAt); Assert.AreEqual(DateTime.Parse("11/16/2015 21:48:26.641"), rfi.CreatedAt); Assert.AreEqual("*****@*****.**", rfi.AssignedTo[0].Email); Assert.AreEqual("*****@*****.**", rfi.UpdatedBy.Email); Assert.AreEqual("*****@*****.**", rfi.CreatedBy.Email); Assert.IsFalse(string.IsNullOrEmpty(rfi.Uid)); Assert.IsTrue(rfi.IsLocked); Page <Photo> photos = await client.Resolve(rfi.Photos); Assert.AreEqual(1, rfi.Photos.TotalCount); Assert.AreEqual(1, photos.TotalCount); Assert.AreEqual(TestData.PhotoUrl, photos.Data[0].Url); Page <Snapshot> snapshots = await client.Resolve(rfi.Snapshots); Assert.AreEqual(1, rfi.Snapshots.TotalCount); Assert.AreEqual(1, snapshots.TotalCount); Assert.AreEqual("AR.1", snapshots.Data[0].Title); Page <Attachment> attachments = await client.Resolve(rfi.Attachments); Assert.AreEqual(1, rfi.Attachments.TotalCount); Assert.AreEqual(1, attachments.TotalCount); Assert.AreEqual("PA1.11.pdf", attachments.Data[0].Name); Page <Comment> comments = await client.Resolve(rfi.Comments); Assert.AreEqual(1, rfi.Comments.TotalCount); Assert.AreEqual(1, comments.TotalCount); Assert.AreEqual("Test Rfi Comment", comments.Data[0].Text); }
public async Task UpdateRfi() { 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 = true, SentAt = new DateTime(2019, 1, 1), StatusUid = TestData.Project2DraftRfiStatusUid, Title = "test title" }; Rfi rfi = await client.CreateRfi(TestData.Project2Uid, rfiInsert); var rfiUpdate = new RfiUpsert { Question = "test question2", Answer = "test answer2", AssignedTo = new[] { TestData.ApiTestsUser2Uid }, DueAt = new DateTime(2020, 1, 2), IsLocked = false, SentAt = new DateTime(2019, 1, 2), StatusUid = TestData.Project2OpenRfiStatusUid, Title = "test title2" }; rfi = await client.UpdateRfi(TestData.Project2Uid, rfi.Uid, rfiUpdate); Assert.AreEqual(rfiUpdate.Question, rfi.Question); Assert.AreEqual(rfiUpdate.Answer, rfi.Answer); Assert.AreEqual(rfiUpdate.AssignedTo[0], rfi.AssignedTo[0].Uid); Assert.AreEqual(rfiUpdate.DueAt, rfi.DueAt); Assert.AreEqual(rfiUpdate.IsLocked, rfi.IsLocked); Assert.AreEqual(rfiUpdate.SentAt, rfi.SentAt); Assert.AreEqual(rfiUpdate.StatusUid, rfi.Status.Uid); Assert.AreEqual(rfiUpdate.Title, rfi.Title); Assert.AreEqual(TestData.ApiTestsUserUid, rfi.CreatedBy.Uid); Assert.AreNotEqual(rfi.CreatedAt, default(DateTime)); Assert.AreEqual(TestData.ApiTestsUserUid, rfi.UpdatedBy.Uid); Assert.AreNotEqual(rfi.UpdatedAt, default(DateTime)); }
private async Task ValidateRfi(Rfi rfi, IPlanGridApi client) { Page<RfiChange> history = await client.GetRfiHistory(TestData.Project1Uid, rfi.Uid); Assert.AreEqual("locked", history.Data[0].Field); Assert.AreEqual(true, (bool)history.Data[0].NewValue); Assert.AreEqual(false, (bool)history.Data[0].OldValue); Assert.AreEqual("Test Rfi Answer", rfi.Answer); Assert.AreEqual("Test Rfi Question", rfi.Question); Assert.AreEqual("Test Rfi", rfi.Title); Assert.AreEqual(1, rfi.Number); Assert.AreEqual(Date.Parse("2015-11-18"), rfi.SentDate); Assert.AreEqual(Date.Parse("2015-11-19"), rfi.DueDate); Assert.AreEqual(DateTime.Parse("11/17/2015 20:06:47.912"), rfi.UpdatedAt); Assert.AreEqual(DateTime.Parse("11/16/2015 21:48:26.641"), rfi.CreatedAt); Assert.AreEqual("*****@*****.**", rfi.AssignedTo[0].Email); Assert.AreEqual("*****@*****.**", rfi.UpdatedBy.Email); Assert.AreEqual("*****@*****.**", rfi.CreatedBy.Email); Assert.IsFalse(string.IsNullOrEmpty(rfi.Uid)); Assert.IsTrue(rfi.IsLocked); Page<Photo> photos = await client.Resolve(rfi.Photos); Assert.AreEqual(1, rfi.Photos.TotalCount); Assert.AreEqual(1, photos.TotalCount); Assert.AreEqual(TestData.PhotoUrl, photos.Data[0].Url); Page<Snapshot> snapshots = await client.Resolve(rfi.Snapshots); Assert.AreEqual(1, rfi.Snapshots.TotalCount); Assert.AreEqual(1, snapshots.TotalCount); Assert.AreEqual("AR.1", snapshots.Data[0].Title); Page<Attachment> attachments = await client.Resolve(rfi.Attachments); Assert.AreEqual(1, rfi.Attachments.TotalCount); Assert.AreEqual(1, attachments.TotalCount); Assert.AreEqual("PA1.11.pdf", attachments.Data[0].Name); Page<Comment> comments = await client.Resolve(rfi.Comments); Assert.AreEqual(1, rfi.Comments.TotalCount); Assert.AreEqual(1, comments.TotalCount); Assert.AreEqual("Test Rfi Comment", comments.Data[0].Text); }
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); }