예제 #1
0
        public async Task ReferencePhoto()
        {
            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);

            await client.ReferencePhotoFromRfi(TestData.Project2Uid, rfi.Uid, new PhotoReference { PhotoUid = TestData.Project2PhotoUid });

            Page <Photo> photos = await client.GetRfiPhotos(TestData.Project2Uid, rfi.Uid);

            Photo rfiPhoto = photos.Data.Single();

            Assert.AreEqual(TestData.Project2PhotoUid, rfiPhoto.Uid);

            await client.RemovePhotoFromRfi(TestData.Project2Uid, rfi.Uid, rfiPhoto.Uid);

            photos = await client.GetRfiPhotos(TestData.Project2Uid, rfi.Uid);

            Assert.AreEqual(0, photos.Data.Length);
        }
예제 #2
0
        public async Task CreateRfi()
        {
            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);

            Assert.AreEqual(rfiInsert.Question, rfi.Question);
            Assert.AreEqual(rfiInsert.Answer, rfi.Answer);
            Assert.AreEqual(rfiInsert.AssignedTo[0], rfi.AssignedTo[0].Uid);
            Assert.AreEqual(rfiInsert.DueAt, rfi.DueAt);
            Assert.AreEqual(rfiInsert.IsLocked, rfi.IsLocked);
            Assert.AreEqual(rfiInsert.SentAt, rfi.SentAt);
            Assert.AreEqual(rfiInsert.StatusUid, rfi.Status.Uid);
            Assert.AreEqual(rfiInsert.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));
        }
예제 #3
0
        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);
        }