-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c55759
commit 3a31178
Showing
44 changed files
with
849 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<appSettings> | ||
<add key="PlanGridApiBaseUrl" value="https://plangrid-c-api-dispatcher-test.herokuapp.com" /> | ||
</appSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// <copyright file="PhotoTests.cs" company="PlanGrid, Inc."> | ||
// Copyright (c) 2016 PlanGrid, Inc. All rights reserved. | ||
// </copyright> | ||
|
||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace PlanGrid.Api.Tests | ||
{ | ||
public class PhotoTests | ||
{ | ||
[Test] | ||
public async Task UploadPngPhoto() | ||
{ | ||
IPlanGridApi client = PlanGridClient.Create(); | ||
Stream payload = typeof(PhotoTests).Assembly.GetManifestResourceStream("PlanGrid.Api.Tests.TestData.Sample.png"); | ||
Photo photo = await client.UploadPngPhoto(TestData.Project2Uid, "test name", payload); | ||
|
||
Assert.AreEqual("test name", photo.Title); | ||
Assert.AreEqual(TestData.ApiTestsUserUid, photo.CreatedBy.Uid); | ||
Assert.AreNotEqual(photo.CreatedAt, default(DateTime)); | ||
|
||
using (var downloader = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, AllowAutoRedirect = true })) | ||
{ | ||
Stream returnedPayload = await downloader.GetStreamAsync(photo.Url); | ||
payload = typeof(PhotoTests).Assembly.GetManifestResourceStream("PlanGrid.Api.Tests.TestData.Sample.png"); | ||
var payloadBytes = new MemoryStream(); | ||
await payload.CopyToAsync(payloadBytes); | ||
var returnedBytes = new MemoryStream(); | ||
await returnedPayload.CopyToAsync(returnedBytes); | ||
Assert.IsTrue(payloadBytes.ToArray().SequenceEqual(returnedBytes.ToArray())); | ||
} | ||
|
||
Photo retrievedPhoto = await client.GetPhotoInProject(TestData.Project2Uid, photo.Uid); | ||
Assert.IsFalse(retrievedPhoto.IsDeleted); | ||
await client.RemovePhoto(TestData.Project2Uid, photo.Uid); | ||
Photo removedPhoto = await client.GetPhotoInProject(TestData.Project2Uid, photo.Uid); | ||
Assert.IsTrue(removedPhoto.IsDeleted); | ||
} | ||
|
||
[Test] | ||
public async Task UploadJpegPhoto() | ||
{ | ||
IPlanGridApi client = PlanGridClient.Create(); | ||
Stream payload = typeof(PhotoTests).Assembly.GetManifestResourceStream("PlanGrid.Api.Tests.TestData.Sample.jpg"); | ||
Photo photo = await client.UploadPngPhoto(TestData.Project2Uid, "test name", payload); | ||
|
||
Assert.AreEqual("test name", photo.Title); | ||
Assert.AreEqual(TestData.ApiTestsUserUid, photo.CreatedBy.Uid); | ||
Assert.AreNotEqual(photo.CreatedAt, default(DateTime)); | ||
|
||
using (var downloader = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, AllowAutoRedirect = true })) | ||
{ | ||
Stream returnedPayload = await downloader.GetStreamAsync(photo.Url); | ||
payload = typeof(PhotoTests).Assembly.GetManifestResourceStream("PlanGrid.Api.Tests.TestData.Sample.jpg"); | ||
var payloadBytes = new MemoryStream(); | ||
await payload.CopyToAsync(payloadBytes); | ||
var returnedBytes = new MemoryStream(); | ||
await returnedPayload.CopyToAsync(returnedBytes); | ||
Assert.IsTrue(payloadBytes.ToArray().SequenceEqual(returnedBytes.ToArray())); | ||
} | ||
|
||
Photo retrievedPhoto = await client.GetPhotoInProject(TestData.Project2Uid, photo.Uid); | ||
Assert.AreEqual("test name", retrievedPhoto.Title); | ||
await client.UpdatePhoto(TestData.Project2Uid, photo.Uid, new PhotoUpdate { Title = "new title" }); | ||
retrievedPhoto = await client.GetPhotoInProject(TestData.Project2Uid, photo.Uid); | ||
Assert.AreEqual("new title", retrievedPhoto.Title); | ||
|
||
Assert.IsFalse(retrievedPhoto.IsDeleted); | ||
await client.RemovePhoto(TestData.Project2Uid, photo.Uid); | ||
Photo removedPhoto = await client.GetPhotoInProject(TestData.Project2Uid, photo.Uid); | ||
Assert.IsTrue(removedPhoto.IsDeleted); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,18 @@ public async Task GetRfis() | |
Assert.AreEqual(1, rfis.TotalCount); | ||
|
||
Rfi rfi = rfis.Data[0]; | ||
|
||
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("11/18/2015 19:30:21.000"), rfi.SentDate); | ||
Assert.AreEqual(DateTime.Parse("11/19/2015 19:30:13.000"), rfi.DueDate); | ||
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("[email protected]", rfi.AssignedTo[0].Email); | ||
|
@@ -207,15 +213,15 @@ public async Task ReferenceAttachment() | |
}; | ||
Rfi rfi = await client.CreateRfi(TestData.Project2Uid, rfiInsert); | ||
|
||
AttachmentUploadRequest request = await client.CreateAttachmentUploadRequest(TestData.Project2Uid, new AttachmentUpload | ||
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(request, payload); | ||
Attachment attachment = await client.Upload<Attachment>(request, payload); | ||
|
||
await client.ReferenceAttachmentFromRfi(TestData.Project2Uid, rfi.Uid, new AttachmentReference { AttachmentUid = attachment.Uid }); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// <copyright file="SheetPacketTests.cs" company="PlanGrid, Inc."> | ||
// Copyright (c) 2016 PlanGrid, Inc. All rights reserved. | ||
// </copyright> | ||
|
||
using System.Net; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace PlanGrid.Api.Tests | ||
{ | ||
[TestFixture] | ||
public class SheetPacketTests | ||
{ | ||
[Test] | ||
public async Task CreateSheetPacket() | ||
{ | ||
IPlanGridApi client = PlanGridClient.Create(); | ||
Page<Sheet> sheets = await client.GetSheets(TestData.Project2Uid); | ||
ShareableObject packetRequest = await client.CreateSheetPacket(TestData.Project2Uid, new SheetPacketRequest | ||
{ | ||
SheetUids = new[] { sheets.Data[0].Uid } | ||
}); | ||
|
||
for (int i = 0;; i++) | ||
{ | ||
ShareableObject obj = await client.GetSheetPacket(TestData.Project2Uid, packetRequest.Uid); | ||
if (obj.Status == Status.Incomplete) | ||
{ | ||
if (i == 10) | ||
{ | ||
Assert.Fail("Timed out after 10 seconds trying to get the packet."); | ||
} | ||
else | ||
{ | ||
await Task.Delay(1000); | ||
} | ||
} | ||
else | ||
{ | ||
var get = new HttpClient(); | ||
HttpResponseMessage response = await get.GetAsync(obj.FileUrl); | ||
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// <copyright file="SheetTests.cs" company="PlanGrid, Inc."> | ||
// Copyright (c) 2016 PlanGrid, Inc. All rights reserved. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace PlanGrid.Api.Tests | ||
{ | ||
[TestFixture] | ||
public class SheetTests | ||
{ | ||
[Test] | ||
public async Task GetSheetsObeysSkip() | ||
{ | ||
IPlanGridApi client = PlanGridClient.Create(); | ||
|
||
Page<Sheet> sheets = await client.GetSheets(TestData.Project1Uid); | ||
Assert.AreEqual("IS.1", sheets.Data[0].Name); | ||
Assert.AreEqual("PA8.21", sheets.Data[1].Name); | ||
sheets = await client.GetSheets(TestData.Project1Uid, 1); | ||
Assert.AreEqual("PA8.21", sheets.Data[0].Name); | ||
} | ||
|
||
[Test] | ||
public async Task GetSheetsObeysUpdatedAfter() | ||
{ | ||
IPlanGridApi client = PlanGridClient.Create(); | ||
|
||
Page<Sheet> sheets = await client.GetSheets(TestData.Project1Uid, updated_after: new DateTime(2015, 12, 11, 19, 38, 16, DateTimeKind.Utc)); | ||
Assert.IsTrue(sheets.Data.Any()); | ||
sheets = await client.GetSheets(TestData.Project1Uid, updated_after: new DateTime(2016, 12, 11, 19, 39, 16, DateTimeKind.Utc)); | ||
Assert.IsFalse(sheets.Data.Any()); | ||
} | ||
|
||
[Test] | ||
public async Task UploadNewVersion() | ||
{ | ||
IPlanGridApi client = PlanGridClient.Create(); | ||
|
||
await client.UploadVersion(TestData.Project2Uid, $"Version.{Guid.NewGuid()}", new VirtualFile { FileName = "Sample.pdf", Data = typeof(SheetTests).Assembly.GetManifestResourceStream("PlanGrid.Api.Tests.TestData.Sample.pdf") }); | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net45" /> | ||
<package id="NUnit" version="2.6.4" targetFramework="net45" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace PlanGrid.Api | ||
{ | ||
public class AttachmentUpdate | ||
{ | ||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
|
||
[JsonProperty("folder")] | ||
public string Folder { get; set; } | ||
} | ||
} |
Oops, something went wrong.