-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/box/box-windows-sdk-v2
- Loading branch information
Showing
49 changed files
with
1,348 additions
and
45 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
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
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 |
---|---|---|
|
@@ -15,13 +15,18 @@ public class BoxSignRequestManagerIntegrationTest : TestInFolder | |
public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_ShouldCreateNewSignRequest() | ||
{ | ||
var fileToSign = await CreateSmallFile(FolderId); | ||
var fileToSign2 = await CreateSmallFile(FolderId); | ||
var signRequestCreateRequest = new BoxSignRequestCreateRequest() | ||
{ | ||
SourceFiles = new List<BoxSignRequestCreateSourceFile>() | ||
{ | ||
new BoxSignRequestCreateSourceFile() | ||
{ | ||
Id = fileToSign.Id | ||
}, | ||
new BoxSignRequestCreateSourceFile() | ||
{ | ||
Id = fileToSign2.Id | ||
} | ||
}, | ||
Signers = new List<BoxSignRequestSignerCreate>() | ||
|
@@ -30,7 +35,8 @@ public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_Shou | |
{ | ||
Email = "[email protected]", | ||
RedirectUrl = new Uri("https://www.box.com/redirect_url_signer_1"), | ||
DeclinedRedirectUrl = new Uri("https://www.box.com/declined_redirect_url_singer_1") | ||
DeclinedRedirectUrl = new Uri("https://www.box.com/declined_redirect_url_singer_1"), | ||
EmbedUrlExternalUserId = UserId | ||
} | ||
}, | ||
ParentFolder = new BoxRequestEntity() | ||
|
@@ -44,10 +50,15 @@ public async Task CreateSignRequestAsync_ForCorrectSignRequestCreateRequest_Shou | |
BoxSignRequest signRequest = await UserClient.SignRequestsManager.CreateSignRequestAsync(signRequestCreateRequest); | ||
Assert.IsNotNull(signRequest.Id); | ||
Assert.AreEqual(signRequestCreateRequest.SourceFiles[0].Id, signRequest.SourceFiles[0].Id); | ||
Assert.AreEqual(signRequestCreateRequest.SourceFiles[1].Id, signRequest.SourceFiles[1].Id); | ||
Assert.AreEqual(signRequestCreateRequest.RedirectUrl.ToString(), signRequest.RedirectUrl.ToString()); | ||
Assert.AreEqual(signRequestCreateRequest.DeclinedRedirectUrl.ToString(), signRequest.DeclinedRedirectUrl.ToString()); | ||
Assert.AreEqual(signRequestCreateRequest.ParentFolder.Id, signRequest.ParentFolder.Id); | ||
|
||
// first signer is the sender with role final_copy_reader, second is the recipient with role signer | ||
Assert.AreEqual(2, signRequest.Signers.Count); | ||
Assert.IsNotNull(signRequest.Signers[1].IframeableEmbedUrl); | ||
|
||
await UserClient.SignRequestsManager.CancelSignRequestAsync(signRequest.Id); | ||
|
||
signRequest = await UserClient.SignRequestsManager.GetSignRequestByIdAsync(signRequest.Id); | ||
|
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 |
---|---|---|
|
@@ -144,7 +144,8 @@ public async Task CreateSignRequest_OptionalParams_Success() | |
"1234", | ||
"text" | ||
) | ||
} | ||
}, | ||
TemplateId = "12345" | ||
}; | ||
|
||
/*** Act ***/ | ||
|
@@ -163,6 +164,7 @@ public async Task CreateSignRequest_OptionalParams_Success() | |
Assert.AreEqual("[email protected]", response.Signers[0].Email); | ||
Assert.AreEqual("https://box.com/redirect_url_signer_1", response.Signers[0].RedirectUrl.ToString()); | ||
Assert.AreEqual("https://box.com/declined_redirect_url_signer_1", response.Signers[0].DeclinedRedirectUrl.ToString()); | ||
Assert.AreEqual("https://app.box.com/embed/sign/document/bf7aaac6/", response.Signers[0].IframeableEmbedUrl); | ||
Assert.AreEqual(1, response.Signers[0].Inputs.Count); | ||
Assert.IsTrue(response.Signers[0].Inputs[0].CheckboxValue.Value); | ||
Assert.AreEqual(BoxSignRequestSingerInputContentType.checkbox, response.Signers[0].Inputs[0].ContentType); | ||
|
@@ -180,6 +182,7 @@ public async Task CreateSignRequest_OptionalParams_Success() | |
Assert.AreEqual(DateTimeOffset.Parse("2021-04-26T08:12:13.982Z"), response.PrefillTags[0].DateValue); | ||
Assert.AreEqual("https://box.com/redirect_url", response.RedirectUrl.ToString()); | ||
Assert.AreEqual("https://box.com/declined_redirect_url", response.DeclinedRedirectUrl.ToString()); | ||
Assert.AreEqual("12345", response.TemplateId); | ||
} | ||
|
||
[TestMethod] | ||
|
@@ -211,6 +214,7 @@ public async Task GetSignRequest_Success() | |
Assert.AreEqual("[email protected]", response.Entries[0].Signers[0].Email); | ||
Assert.AreEqual("https://box.com/redirect_url_signer_1", response.Entries[0].Signers[0].RedirectUrl.ToString()); | ||
Assert.AreEqual("https://box.com/declined_redirect_url_signer_1", response.Entries[0].Signers[0].DeclinedRedirectUrl.ToString()); | ||
Assert.AreEqual("https://app.box.com/embed/sign/document/bf7aaac6/", response.Entries[0].Signers[0].IframeableEmbedUrl); | ||
Assert.AreEqual("12345", response.Entries[0].ParentFolder.Id); | ||
Assert.IsTrue(response.Entries[0].IsDocumentPreparationNeeded); | ||
Assert.IsTrue(response.Entries[0].AreRemindersEnabled); | ||
|
@@ -257,6 +261,7 @@ public async Task GetSignRequestById_Success() | |
Assert.AreEqual("[email protected]", response.Signers[0].Email); | ||
Assert.AreEqual("https://box.com/redirect_url_signer_1", response.Signers[0].RedirectUrl.ToString()); | ||
Assert.AreEqual("https://box.com/declined_redirect_url_signer_1", response.Signers[0].DeclinedRedirectUrl.ToString()); | ||
Assert.AreEqual("https://app.box.com/embed/sign/document/bf7aaac6/", response.Signers[0].IframeableEmbedUrl); | ||
Assert.AreEqual(1, response.Signers[0].Inputs.Count); | ||
Assert.IsTrue(response.Signers[0].Inputs[0].CheckboxValue.Value); | ||
Assert.AreEqual(BoxSignRequestSingerInputContentType.checkbox, response.Signers[0].Inputs[0].ContentType); | ||
|
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,85 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Box.V2.Managers; | ||
using Box.V2.Models; | ||
using Box.V2.Models.Request; | ||
using Box.V2.Test.Extensions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Box.V2.Test | ||
{ | ||
[TestClass] | ||
public class BoxSignTemplatesManagerTest : BoxResourceManagerTest | ||
{ | ||
private readonly BoxSignTemplatesManager _signTemplatesManager; | ||
|
||
public BoxSignTemplatesManagerTest() | ||
{ | ||
_signTemplatesManager = new BoxSignTemplatesManager(Config.Object, Service, Converter, AuthRepository); | ||
} | ||
|
||
[TestMethod] | ||
public async Task GetSignTemplateById_Success() | ||
{ | ||
/** Arrange **/ | ||
const string signTemplateId = "93153068-5420-467b-b8ef-8e54bfb7be42"; | ||
IBoxRequest boxRequest = null; | ||
Handler.Setup(h => h.ExecuteAsync<BoxSignTemplate>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxSignTemplate>>(new BoxResponse<BoxSignTemplate>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxSignTemplate/GetSignTemplate200.json") | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
/*** Act ***/ | ||
BoxSignTemplate response = await _signTemplatesManager.GetSignTemplateByIdAsync(signTemplateId); | ||
|
||
/*** Assert ***/ | ||
// Request check | ||
Assert.IsNotNull(boxRequest); | ||
Assert.AreEqual(RequestMethod.Get, boxRequest.Method); | ||
Assert.AreEqual(new Uri("https://api.box.com/2.0/sign_templates/93153068-5420-467b-b8ef-8e54bfb7be42"), boxRequest.AbsoluteUri); | ||
|
||
// Response check | ||
Assert.AreEqual(signTemplateId, response.Id); | ||
Assert.AreEqual("requirements-dev.pdf", response.Name); | ||
Assert.AreEqual("Please sign this document.\n\nKind regards", response.EmailMessage); | ||
Assert.AreEqual("Someone ([email protected]) has requested your signature on a document", response.EmailSubject); | ||
Assert.AreEqual("1234567890", response.ParentFolder.Id); | ||
Assert.AreEqual(1, response.SourceFiles.Count); | ||
Assert.AreEqual("1234567890", response.SourceFiles[0].Id); | ||
Assert.AreEqual("https://app.box.com/sign/ready-sign-link/59917816-c12b-4ef6-8f1d-aaaaaaa", response.ReadySignLink.Url); | ||
} | ||
|
||
[TestMethod] | ||
public async Task GetSignTemplates_Success() | ||
{ | ||
/** Arrange **/ | ||
IBoxRequest boxRequest = null; | ||
Handler.Setup(h => h.ExecuteAsync<BoxCollectionMarkerBased<BoxSignTemplate>>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxCollectionMarkerBased<BoxSignTemplate>>>(new BoxResponse<BoxCollectionMarkerBased<BoxSignTemplate>>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxSignTemplate/GetAllSignTemplates200.json") | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
/*** Act ***/ | ||
BoxCollectionMarkerBased<BoxSignTemplate> response = await _signTemplatesManager.GetSignTemplatesAsync(1000, "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii"); | ||
|
||
/*** Assert ***/ | ||
// Request check | ||
Assert.IsNotNull(boxRequest); | ||
Assert.AreEqual(RequestMethod.Get, boxRequest.Method); | ||
Assert.AreEqual(new Uri("https://api.box.com/2.0/sign_templates?limit=1000&marker=JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii"), boxRequest.AbsoluteUri); | ||
|
||
// Response check | ||
Assert.AreEqual(1, response.Entries.Count); | ||
Assert.AreEqual("93153068-5420-467b-b8ef-8e54bfb7be42", response.Entries[0].Id); | ||
} | ||
} | ||
} |
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,50 @@ | ||
using Box.V2.Converter; | ||
using Box.V2.Models; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Box.V2.Test | ||
{ | ||
[TestClass] | ||
public class SingleOrCollectionConverterTest : BoxResourceManagerTest | ||
{ | ||
private readonly IBoxConverter _converter; | ||
|
||
public SingleOrCollectionConverterTest() | ||
{ | ||
_converter = new BoxJsonConverter(); | ||
} | ||
|
||
[TestMethod] | ||
public void SingleObject() | ||
{ | ||
var json = LoadFixtureFromJson("Fixtures/Converters/SingleOrCollectionConverter/SingleObject.json"); | ||
var error = _converter.Parse<BoxConflictErrorContextInfo<BoxFolder>>(json); | ||
Assert.AreEqual(error.Conflicts[0].Name, "Test Folder"); | ||
} | ||
|
||
[TestMethod] | ||
public void Array() | ||
{ | ||
var json = LoadFixtureFromJson("Fixtures/Converters/SingleOrCollectionConverter/Array.json"); | ||
var error = _converter.Parse<BoxConflictErrorContextInfo<BoxFolder>>(json); | ||
Assert.AreEqual(error.Conflicts[0].Name, "Test Folder"); | ||
Assert.AreEqual(error.Conflicts[1].Name, "Test Folder 2"); | ||
} | ||
|
||
[TestMethod] | ||
public void EmptyArray() | ||
{ | ||
var json = LoadFixtureFromJson("Fixtures/Converters/SingleOrCollectionConverter/EmptyArray.json"); | ||
var error = _converter.Parse<BoxConflictErrorContextInfo<BoxFolder>>(json); | ||
Assert.AreEqual(error.Conflicts.Count, 0); | ||
} | ||
|
||
[TestMethod] | ||
public void Empty() | ||
{ | ||
var json = LoadFixtureFromJson("Fixtures/Converters/SingleOrCollectionConverter/Empty.json"); | ||
var error = _converter.Parse<BoxConflictErrorContextInfo<BoxFolder>>(json); | ||
Assert.IsNull(error.Conflicts); | ||
} | ||
} | ||
} |
Oops, something went wrong.