-
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.
- Loading branch information
Showing
18 changed files
with
705 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Box.V2.Managers; | ||
using Box.V2.Models; | ||
using Box.V2.Models.Request; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
|
||
namespace Box.V2.Test | ||
{ | ||
[TestClass] | ||
public class BoxFileRequestsManagerTest : BoxResourceManagerTest | ||
{ | ||
private readonly BoxFileRequestsManager _fileRequestsManager; | ||
|
||
public BoxFileRequestsManagerTest() | ||
{ | ||
_fileRequestsManager = new BoxFileRequestsManager(Config.Object, Service, Converter, AuthRepository); | ||
} | ||
|
||
[TestMethod] | ||
[TestCategory("CI-UNIT-TEST")] | ||
public async Task GetFileRequestById_Success() | ||
{ | ||
/*** Arrange ***/ | ||
IBoxRequest boxRequest = null; | ||
Handler.Setup(h => h.ExecuteAsync<BoxFileRequestObject>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxFileRequestObject>>(new BoxResponse<BoxFileRequestObject>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxFileRequest/GetFileRequest200.json") | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
/*** Act ***/ | ||
BoxFileRequestObject response = await _fileRequestsManager.GetFileRequestByIdAsync("42037322"); | ||
|
||
/*** Assert ***/ | ||
// Request check | ||
Assert.IsNotNull(boxRequest); | ||
Assert.AreEqual(RequestMethod.Get, boxRequest.Method); | ||
Assert.AreEqual(new Uri("https://api.box.com/2.0/file_requests/42037322"), boxRequest.AbsoluteUri); | ||
|
||
// Response check | ||
Assert.AreEqual("42037322", response.Id); | ||
Assert.AreEqual(DateTimeOffset.Parse("2020-09-28T10:53:43-08:00"), response.CreatedAt); | ||
Assert.AreEqual("[email protected]", response.CreatedBy.Login); | ||
Assert.AreEqual("Aaron Levie", response.CreatedBy.Name); | ||
Assert.AreEqual("Following documents are requested for your process", response.Description); | ||
Assert.AreEqual("1", response.Etag); | ||
Assert.AreEqual(DateTimeOffset.Parse("2020-09-28T10:53:43-08:00"), response.ExpiresAt); | ||
Assert.AreEqual("12345", response.Folder.Id); | ||
Assert.AreEqual("Contracts", response.Folder.Name); | ||
Assert.AreEqual(true, response.IsDescriptionRequired); | ||
Assert.AreEqual(true, response.IsEmailRequired); | ||
Assert.AreEqual(BoxFileRequestStatus.active, response.Status); | ||
Assert.AreEqual("Please upload documents", response.Title); | ||
Assert.AreEqual(DateTimeOffset.Parse("2020-09-28T10:53:43-08:00"), response.UpdatedAt); | ||
Assert.AreEqual("11446498", response.UpdatedBy.Id); | ||
Assert.AreEqual("[email protected]", response.UpdatedBy.Login); | ||
Assert.AreEqual("Aaron Levie", response.UpdatedBy.Name); | ||
Assert.AreEqual("/f/19e57f40ace247278a8e3d336678c64a", response.Url); | ||
} | ||
|
||
[TestMethod] | ||
[TestCategory("CI-UNIT-TEST")] | ||
public async Task CopyFileRequest_Success() | ||
{ | ||
/*** Arrange ***/ | ||
IBoxRequest boxRequest = null; | ||
Handler.Setup(h => h.ExecuteAsync<BoxFileRequestObject>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxFileRequestObject>>(new BoxResponse<BoxFileRequestObject>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxFileRequest/CopyFileRequest200.json") | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
var folder = new BoxRequestEntity() | ||
{ | ||
Id = "44444", | ||
Type = BoxType.folder | ||
}; | ||
var copyRequest = new BoxFileRequestCopyRequest | ||
{ | ||
Folder = folder | ||
}; | ||
|
||
/*** Act ***/ | ||
BoxFileRequestObject response = await _fileRequestsManager.CopyFileRequestAsync("42037322", copyRequest); | ||
|
||
/*** Assert ***/ | ||
// Request check | ||
Assert.IsNotNull(boxRequest); | ||
Assert.AreEqual(RequestMethod.Post, boxRequest.Method); | ||
Assert.AreEqual(new Uri("https://api.box.com/2.0/file_requests/42037322/copy"), boxRequest.AbsoluteUri); | ||
|
||
// Response check | ||
Assert.AreEqual("42037322", response.Id); | ||
Assert.AreEqual(DateTimeOffset.Parse("2020-09-28T10:53:43-08:00"), response.CreatedAt); | ||
Assert.AreEqual("[email protected]", response.CreatedBy.Login); | ||
Assert.AreEqual("Aaron Levie", response.CreatedBy.Name); | ||
Assert.AreEqual("Following documents are requested for your process", response.Description); | ||
Assert.AreEqual("1", response.Etag); | ||
Assert.AreEqual(DateTimeOffset.Parse("2020-09-28T10:53:43-08:00"), response.ExpiresAt); | ||
Assert.AreEqual("44444", response.Folder.Id); | ||
Assert.AreEqual("Contracts2", response.Folder.Name); | ||
Assert.AreEqual(true, response.IsDescriptionRequired); | ||
Assert.AreEqual(true, response.IsEmailRequired); | ||
Assert.AreEqual(BoxFileRequestStatus.active, response.Status); | ||
Assert.AreEqual("Please upload documents", response.Title); | ||
Assert.AreEqual(DateTimeOffset.Parse("2020-09-28T10:53:43-08:00"), response.UpdatedAt); | ||
Assert.AreEqual("11446498", response.UpdatedBy.Id); | ||
Assert.AreEqual("[email protected]", response.UpdatedBy.Login); | ||
Assert.AreEqual("Aaron Levie", response.UpdatedBy.Name); | ||
Assert.AreEqual("/f/19e57f40ace247278a8e3d336678c64a", response.Url); | ||
} | ||
|
||
[TestMethod] | ||
[TestCategory("CI-UNIT-TEST")] | ||
public async Task UpdateFileRequest_Success() | ||
{ | ||
/*** Arrange ***/ | ||
IBoxRequest boxRequest = null; | ||
Handler.Setup(h => h.ExecuteAsync<BoxFileRequestObject>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxFileRequestObject>>(new BoxResponse<BoxFileRequestObject>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxFileRequest/UpdateFileRequest200.json") | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
var updateRequest = new BoxFileRequestUpdateRequest | ||
{ | ||
Description = "New, updated description", | ||
ExpiresAt = DateTimeOffset.Parse("2021-09-28T10:53:43-08:00"), | ||
IsEmailRequired = false, | ||
Status = BoxFileRequestStatus.inactive | ||
}; | ||
|
||
/*** Act ***/ | ||
BoxFileRequestObject response = await _fileRequestsManager.UpdateFileRequestAsync("42037322", updateRequest); | ||
|
||
/*** Assert ***/ | ||
// Request check | ||
Assert.IsNotNull(boxRequest); | ||
Assert.AreEqual(RequestMethod.Put, boxRequest.Method); | ||
Assert.AreEqual(new Uri("https://api.box.com/2.0/file_requests/42037322"), boxRequest.AbsoluteUri); | ||
|
||
// Response check | ||
Assert.AreEqual("42037322", response.Id); | ||
Assert.AreEqual(DateTimeOffset.Parse("2020-09-28T10:53:43-08:00"), response.CreatedAt); | ||
Assert.AreEqual("[email protected]", response.CreatedBy.Login); | ||
Assert.AreEqual("Aaron Levie", response.CreatedBy.Name); | ||
Assert.AreEqual("New, updated description", response.Description); | ||
Assert.AreEqual("1", response.Etag); | ||
Assert.AreEqual(DateTimeOffset.Parse("2021-09-28T10:53:43-08:00"), response.ExpiresAt); | ||
Assert.AreEqual("12345", response.Folder.Id); | ||
Assert.AreEqual("Contracts", response.Folder.Name); | ||
Assert.AreEqual(true, response.IsDescriptionRequired); | ||
Assert.AreEqual(false, response.IsEmailRequired); | ||
Assert.AreEqual(BoxFileRequestStatus.inactive, response.Status); | ||
Assert.AreEqual("Please upload documents", response.Title); | ||
Assert.AreEqual(DateTimeOffset.Parse("2020-09-28T10:53:43-08:00"), response.UpdatedAt); | ||
Assert.AreEqual("11446498", response.UpdatedBy.Id); | ||
Assert.AreEqual("[email protected]", response.UpdatedBy.Login); | ||
Assert.AreEqual("Aaron Levie", response.UpdatedBy.Name); | ||
Assert.AreEqual("/f/19e57f40ace247278a8e3d336678c64a", response.Url); | ||
} | ||
|
||
[TestMethod] | ||
[TestCategory("CI-UNIT-TEST")] | ||
public async Task DeleteFileRequest_Success() | ||
{ | ||
/*** Arrange ***/ | ||
IBoxRequest boxRequest = null; | ||
Handler.Setup(h => h.ExecuteAsync<object>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<object>>(new BoxResponse<object>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
/*** Act ***/ | ||
var response = await _fileRequestsManager.DeleteFileRequestAsync("42037322"); | ||
|
||
/*** Assert ***/ | ||
// Request check | ||
Assert.IsNotNull(boxRequest); | ||
Assert.AreEqual(RequestMethod.Delete, boxRequest.Method); | ||
Assert.AreEqual(new Uri("https://api.box.com/2.0/file_requests/42037322"), boxRequest.AbsoluteUri); | ||
|
||
// Response check | ||
Assert.AreEqual(true, response); | ||
} | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
Box.V2.Test/Fixtures/BoxFileRequest/CopyFileRequest200.json
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,33 @@ | ||
{ | ||
"id": 42037322, | ||
"type": "file_request", | ||
"created_at": "2020-09-28T10:53:43-08:00", | ||
"created_by": { | ||
"id": 11446498, | ||
"type": "user", | ||
"login": "[email protected]", | ||
"name": "Aaron Levie" | ||
}, | ||
"description": "Following documents are requested for your process", | ||
"etag": 1, | ||
"expires_at": "2020-09-28T10:53:43-08:00", | ||
"folder": { | ||
"id": 44444, | ||
"type": "folder", | ||
"etag": 1, | ||
"name": "Contracts2", | ||
"sequence_id": 3 | ||
}, | ||
"is_description_required": true, | ||
"is_email_required": true, | ||
"status": "active", | ||
"title": "Please upload documents", | ||
"updated_at": "2020-09-28T10:53:43-08:00", | ||
"updated_by": { | ||
"id": 11446498, | ||
"type": "user", | ||
"login": "[email protected]", | ||
"name": "Aaron Levie" | ||
}, | ||
"url": "/f/19e57f40ace247278a8e3d336678c64a" | ||
} |
33 changes: 33 additions & 0 deletions
33
Box.V2.Test/Fixtures/BoxFileRequest/GetFileRequest200.json
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,33 @@ | ||
{ | ||
"id": 42037322, | ||
"type": "file_request", | ||
"created_at": "2020-09-28T10:53:43-08:00", | ||
"created_by": { | ||
"id": 11446498, | ||
"type": "user", | ||
"login": "[email protected]", | ||
"name": "Aaron Levie" | ||
}, | ||
"description": "Following documents are requested for your process", | ||
"etag": 1, | ||
"expires_at": "2020-09-28T10:53:43-08:00", | ||
"folder": { | ||
"id": 12345, | ||
"type": "folder", | ||
"etag": 1, | ||
"name": "Contracts", | ||
"sequence_id": 3 | ||
}, | ||
"is_description_required": true, | ||
"is_email_required": true, | ||
"status": "active", | ||
"title": "Please upload documents", | ||
"updated_at": "2020-09-28T10:53:43-08:00", | ||
"updated_by": { | ||
"id": 11446498, | ||
"type": "user", | ||
"login": "[email protected]", | ||
"name": "Aaron Levie" | ||
}, | ||
"url": "/f/19e57f40ace247278a8e3d336678c64a" | ||
} |
33 changes: 33 additions & 0 deletions
33
Box.V2.Test/Fixtures/BoxFileRequest/UpdateFileRequest200.json
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,33 @@ | ||
{ | ||
"id": 42037322, | ||
"type": "file_request", | ||
"created_at": "2020-09-28T10:53:43-08:00", | ||
"created_by": { | ||
"id": 11446498, | ||
"type": "user", | ||
"login": "[email protected]", | ||
"name": "Aaron Levie" | ||
}, | ||
"description": "New, updated description", | ||
"etag": 1, | ||
"expires_at": "2021-09-28T10:53:43-08:00", | ||
"folder": { | ||
"id": 12345, | ||
"type": "folder", | ||
"etag": 1, | ||
"name": "Contracts", | ||
"sequence_id": 3 | ||
}, | ||
"is_description_required": true, | ||
"is_email_required": false, | ||
"status": "inactive", | ||
"title": "Please upload documents", | ||
"updated_at": "2020-09-28T10:53:43-08:00", | ||
"updated_by": { | ||
"id": 11446498, | ||
"type": "user", | ||
"login": "[email protected]", | ||
"name": "Aaron Levie" | ||
}, | ||
"url": "/f/19e57f40ace247278a8e3d336678c64a" | ||
} |
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
Oops, something went wrong.