-
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
15 changed files
with
375 additions
and
6 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 |
---|---|---|
|
@@ -412,12 +412,11 @@ public async Task CopyFile_ValidResponse_ValidFile() | |
public async Task CreateFileSharedLink_ValidResponse_ValidFile() | ||
{ | ||
/*** Arrange ***/ | ||
var responseString = "{ \"type\": \"file\", \"id\": \"5000948880\", \"sequence_id\": \"3\", \"etag\": \"3\", \"sha1\": \"134b65991ed521fcfe4724b7d814ab8ded5185dc\", \"name\": \"tigers.jpeg\", \"description\": \"a picture of tigers\", \"size\": 629644, \"path_collection\": { \"total_count\": 2, \"entries\": [ { \"type\": \"folder\", \"id\": \"0\", \"sequence_id\": null, \"etag\": null, \"name\": \"All Files\" }, { \"type\": \"folder\", \"id\": \"11446498\", \"sequence_id\": \"1\", \"etag\": \"1\", \"name\": \"Pictures\" } ] }, \"created_at\": \"2012-12-12T10:55:30-08:00\", \"modified_at\": \"2012-12-12T11:04:26-08:00\", \"created_by\": { \"type\": \"user\", \"id\": \"17738362\", \"name\": \"sean rose\", \"login\": \"[email protected]\" }, \"modified_by\": { \"type\": \"user\", \"id\": \"17738362\", \"name\": \"sean rose\", \"login\": \"[email protected]\" }, \"owned_by\": { \"type\": \"user\", \"id\": \"17738362\", \"name\": \"sean rose\", \"login\": \"[email protected]\" }, \"shared_link\": { \"url\": \"https://www.box.com/s/rh935iit6ewrmw0unyul\", \"download_url\": \"https://www.box.com/shared/static/rh935iit6ewrmw0unyul.jpeg\", \"vanity_url\": null, \"vanity_name\": \"my-custom-vanity-name\", \"is_password_enabled\": false, \"unshared_at\": null, \"download_count\": 0, \"preview_count\": 0, \"access\": \"open\", \"permissions\": { \"can_download\": true, \"can_preview\": true } }, \"parent\": { \"type\": \"folder\", \"id\": \"11446498\", \"sequence_id\": \"1\", \"etag\": \"1\", \"name\": \"Pictures\" }, \"item_status\": \"active\" }"; | ||
Handler.Setup(h => h.ExecuteAsync<BoxFile>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxFile>>(new BoxResponse<BoxFile>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = responseString | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxFiles/CreateFileSharedLink200.json") | ||
})); | ||
|
||
var sharedLink = new BoxSharedLinkRequest() | ||
|
@@ -440,6 +439,7 @@ public async Task CreateFileSharedLink_ValidResponse_ValidFile() | |
Assert.AreEqual("user", f.CreatedBy.Type); | ||
Assert.AreEqual("17738362", f.CreatedBy.Id); | ||
Assert.AreEqual("my-custom-vanity-name", f.SharedLink.VanityName); | ||
Assert.AreEqual(true, f.SharedLink.Permissions.CanEdit); | ||
} | ||
|
||
[TestMethod] | ||
|
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 |
---|---|---|
|
@@ -586,7 +586,7 @@ public async Task CreateFolderSharedLink_ValidResponse_ValidFolder() | |
.Returns(() => Task.FromResult<IBoxResponse<BoxFolder>>(new BoxResponse<BoxFolder>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = "{ \"type\": \"folder\", \"id\": \"11446498\", \"sequence_id\": \"1\", \"etag\": \"1\", \"name\": \"Pictures\", \"created_at\": \"2012-12-12T10:53:43-08:00\", \"modified_at\": \"2012-12-12T11:15:04-08:00\", \"description\": \"Some pictures I took\", \"size\": 629644, \"path_collection\": { \"total_count\": 1, \"entries\": [ { \"type\": \"folder\", \"id\": \"0\", \"sequence_id\": null, \"etag\": null, \"name\": \"All Files\" } ] }, \"created_by\": { \"type\": \"user\", \"id\": \"17738362\", \"name\": \"sean rose\", \"login\": \"[email protected]\" }, \"modified_by\": { \"type\": \"user\", \"id\": \"17738362\", \"name\": \"sean rose\", \"login\": \"[email protected]\" }, \"owned_by\": { \"type\": \"user\", \"id\": \"17738362\", \"name\": \"sean rose\", \"login\": \"[email protected]\" }, \"shared_link\": { \"url\": \"https://www.box.com/s/vspke7y05sb214wjokpk\", \"download_url\": \"https://www.box.com/shared/static/vspke7y05sb214wjokpk\", \"vanity_url\": null, \"vanity_name\": \"my-custom-vanity-name\", \"is_password_enabled\": false, \"unshared_at\": null, \"download_count\": 0, \"preview_count\": 0, \"access\": \"open\", \"permissions\": { \"can_download\": true, \"can_preview\": true } }, \"folder_upload_email\": { \"access\": \"open\", \"email\": \"[email protected]\" }, \"parent\": { \"type\": \"folder\", \"id\": \"0\", \"sequence_id\": null, \"etag\": null, \"name\": \"All Files\" }, \"item_status\": \"active\", \"item_collection\": { \"total_count\": 1, \"entries\": [ { \"type\": \"file\", \"id\": \"5000948880\", \"sequence_id\": \"3\", \"etag\": \"3\", \"sha1\": \"134b65991ed521fcfe4724b7d814ab8ded5185dc\", \"name\": \"tigers.jpeg\" } ], \"offset\": 0, \"limit\": 100 } }" | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxFolders/CreateFolderSharedLink200.json") | ||
})); | ||
|
||
/*** Act ***/ | ||
|
@@ -605,6 +605,34 @@ public async Task CreateFolderSharedLink_ValidResponse_ValidFolder() | |
Assert.AreEqual("1", f.ETag); | ||
Assert.AreEqual("Pictures", f.Name); | ||
Assert.AreEqual("my-custom-vanity-name", f.SharedLink.VanityName); | ||
Assert.AreEqual(false, f.SharedLink.Permissions.CanEdit); | ||
} | ||
|
||
[TestMethod] | ||
public async Task CreateFolderSharedLink_ShouldThrowArgumentException_WhenEditIsTrue() | ||
{ | ||
/*** Arrange ***/ | ||
IBoxRequest boxRequest = null; | ||
Handler.Setup(h => h.ExecuteAsync<BoxFolder>(It.IsAny<IBoxRequest>())) | ||
.Returns(() => Task.FromResult<IBoxResponse<BoxFolder>>(new BoxResponse<BoxFolder>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxFolders/CreateFolderSharedLink200.json") | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
var sharedLink = new BoxSharedLinkRequest() | ||
{ | ||
Access = BoxSharedLinkAccessType.collaborators, | ||
VanityName = "my-custom-vanity-name", | ||
Permissions = new BoxPermissionsRequest | ||
{ | ||
Edit = true | ||
} | ||
}; | ||
|
||
/*** Act && Assert ***/ | ||
await Assert.ThrowsExceptionAsync<ArgumentException>(async () => { _ = await _foldersManager.CreateSharedLinkAsync("12345", sharedLink); }); | ||
} | ||
|
||
[TestMethod] | ||
|
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 |
---|---|---|
|
@@ -457,22 +457,21 @@ public async Task Copy_ValidResponse() | |
public async Task CreateWebLinkSharedLink_ValidResponse_ValidFile() | ||
{ | ||
/*** Arrange ***/ | ||
var responseString = "{ \"type\": \"web_link\", \"id\": \"5000948880\", \"sequence_id\": \"3\", \"etag\": \"3\", \"sha1\": \"134b65991ed521fcfe4724b7d814ab8ded5185dc\", \"name\": \"tigers.jpeg\", \"description\": \"a picture of tigers\", \"size\": 629644, \"path_collection\": { \"total_count\": 2, \"entries\": [ { \"type\": \"folder\", \"id\": \"0\", \"sequence_id\": null, \"etag\": null, \"name\": \"All Files\" }, { \"type\": \"folder\", \"id\": \"11446498\", \"sequence_id\": \"1\", \"etag\": \"1\", \"name\": \"Pictures\" } ] }, \"created_at\": \"2012-12-12T10:55:30-08:00\", \"modified_at\": \"2012-12-12T11:04:26-08:00\", \"created_by\": { \"type\": \"user\", \"id\": \"17738362\", \"name\": \"sean rose\", \"login\": \"[email protected]\" }, \"modified_by\": { \"type\": \"user\", \"id\": \"17738362\", \"name\": \"sean rose\", \"login\": \"[email protected]\" }, \"owned_by\": { \"type\": \"user\", \"id\": \"17738362\", \"name\": \"sean rose\", \"login\": \"[email protected]\" }, \"shared_link\": { \"url\": \"https://www.box.com/s/rh935iit6ewrmw0unyul\", \"vanity_name\": \"my-custom-vanity-name\", \"download_url\": \"https://www.box.com/shared/static/rh935iit6ewrmw0unyul.jpeg\", \"vanity_url\": null, \"is_password_enabled\": false, \"unshared_at\": null, \"download_count\": 0, \"preview_count\": 0, \"access\": \"open\", \"permissions\": { \"can_download\": true, \"can_preview\": true } }, \"parent\": { \"type\": \"folder\", \"id\": \"11446498\", \"sequence_id\": \"1\", \"etag\": \"1\", \"name\": \"Pictures\" }, \"item_status\": \"active\" }"; | ||
IBoxRequest boxRequest = null; | ||
var webLinksUri = new Uri(Constants.WebLinksEndpointString); | ||
Config.SetupGet(x => x.WebLinksEndpointUri).Returns(webLinksUri); | ||
Handler.Setup(h => h.ExecuteAsync<BoxWebLink>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxWebLink>>(new BoxResponse<BoxWebLink>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = responseString | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxWebLinks/CreateWebLinkSharedLink200.json") | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
var sharedLink = new BoxSharedLinkRequest() | ||
{ | ||
Access = BoxSharedLinkAccessType.collaborators, | ||
VanityName = "my-custom-vanity-name" | ||
VanityName = "my-custom-vanity-name", | ||
}; | ||
|
||
/*** Act ***/ | ||
|
@@ -490,6 +489,33 @@ public async Task CreateWebLinkSharedLink_ValidResponse_ValidFile() | |
Assert.AreEqual("my-custom-vanity-name", w.SharedLink.VanityName); | ||
} | ||
|
||
[TestMethod] | ||
public async Task CreateWebLinkSharedLink_ShouldThrowArgumentException_WhenEditIsTrue() | ||
{ | ||
/*** Arrange ***/ | ||
IBoxRequest boxRequest = null; | ||
Handler.Setup(h => h.ExecuteAsync<BoxWebLink>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxWebLink>>(new BoxResponse<BoxWebLink>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxWebLinks/CreateWebLinkSharedLink200.json") | ||
})) | ||
.Callback<IBoxRequest>(r => boxRequest = r); | ||
|
||
var sharedLink = new BoxSharedLinkRequest() | ||
{ | ||
Access = BoxSharedLinkAccessType.collaborators, | ||
VanityName = "my-custom-vanity-name", | ||
Permissions = new BoxPermissionsRequest | ||
{ | ||
Edit = true | ||
} | ||
}; | ||
|
||
/*** Act && Assert ***/ | ||
await Assert.ThrowsExceptionAsync<ArgumentException>(async () => { _ = await _webLinkManager.CreateSharedLinkAsync("12345", sharedLink); }); | ||
} | ||
|
||
[TestMethod] | ||
public async Task DeleteWebLinkSharedLink_ValidResponse_ValidFile() | ||
{ | ||
|
73 changes: 73 additions & 0 deletions
73
Box.V2.Test/Fixtures/BoxFiles/CreateFileSharedLink200.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,73 @@ | ||
{ | ||
"type": "file", | ||
"id": "5000948880", | ||
"sequence_id": "3", | ||
"etag": "3", | ||
"sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc", | ||
"name": "tigers.jpeg", | ||
"description": "a picture of tigers", | ||
"size": 629644, | ||
"path_collection": { | ||
"total_count": 2, | ||
"entries": [ | ||
{ | ||
"type": "folder", | ||
"id": "0", | ||
"sequence_id": null, | ||
"etag": null, | ||
"name": "All Files" | ||
}, | ||
{ | ||
"type": "folder", | ||
"id": "11446498", | ||
"sequence_id": "1", | ||
"etag": "1", | ||
"name": "Pictures" | ||
} | ||
] | ||
}, | ||
"created_at": "2012-12-12T10:55:30-08:00", | ||
"modified_at": "2012-12-12T11:04:26-08:00", | ||
"created_by": { | ||
"type": "user", | ||
"id": "17738362", | ||
"name": "sean rose", | ||
"login": "[email protected]" | ||
}, | ||
"modified_by": { | ||
"type": "user", | ||
"id": "17738362", | ||
"name": "sean rose", | ||
"login": "[email protected]" | ||
}, | ||
"owned_by": { | ||
"type": "user", | ||
"id": "17738362", | ||
"name": "sean rose", | ||
"login": "[email protected]" | ||
}, | ||
"shared_link": { | ||
"url": "https://www.box.com/s/rh935iit6ewrmw0unyul", | ||
"download_url": "https://www.box.com/shared/static/rh935iit6ewrmw0unyul.jpeg", | ||
"vanity_url": null, | ||
"vanity_name": "my-custom-vanity-name", | ||
"is_password_enabled": false, | ||
"unshared_at": null, | ||
"download_count": 0, | ||
"preview_count": 0, | ||
"access": "open", | ||
"permissions": { | ||
"can_download": true, | ||
"can_preview": true, | ||
"can_edit": true | ||
} | ||
}, | ||
"parent": { | ||
"type": "folder", | ||
"id": "11446498", | ||
"sequence_id": "1", | ||
"etag": "1", | ||
"name": "Pictures" | ||
}, | ||
"item_status": "active" | ||
} |
84 changes: 84 additions & 0 deletions
84
Box.V2.Test/Fixtures/BoxFolders/CreateFolderSharedLink200.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,84 @@ | ||
{ | ||
"type": "folder", | ||
"id": "11446498", | ||
"sequence_id": "1", | ||
"etag": "1", | ||
"name": "Pictures", | ||
"created_at": "2012-12-12T10:53:43-08:00", | ||
"modified_at": "2012-12-12T11:15:04-08:00", | ||
"description": "Some pictures I took", | ||
"size": 629644, | ||
"path_collection": { | ||
"total_count": 1, | ||
"entries": [ | ||
{ | ||
"type": "folder", | ||
"id": "0", | ||
"sequence_id": null, | ||
"etag": null, | ||
"name": "All Files" | ||
} | ||
] | ||
}, | ||
"created_by": { | ||
"type": "user", | ||
"id": "17738362", | ||
"name": "sean rose", | ||
"login": "[email protected]" | ||
}, | ||
"modified_by": { | ||
"type": "user", | ||
"id": "17738362", | ||
"name": "sean rose", | ||
"login": "[email protected]" | ||
}, | ||
"owned_by": { | ||
"type": "user", | ||
"id": "17738362", | ||
"name": "sean rose", | ||
"login": "[email protected]" | ||
}, | ||
"shared_link": { | ||
"url": "https://www.box.com/s/vspke7y05sb214wjokpk", | ||
"download_url": "https://www.box.com/shared/static/vspke7y05sb214wjokpk", | ||
"vanity_url": null, | ||
"vanity_name": "my-custom-vanity-name", | ||
"is_password_enabled": false, | ||
"unshared_at": null, | ||
"download_count": 0, | ||
"preview_count": 0, | ||
"access": "open", | ||
"permissions": { | ||
"can_download": true, | ||
"can_preview": true, | ||
"can_edit" : false | ||
} | ||
}, | ||
"folder_upload_email": { | ||
"access": "open", | ||
"email": "[email protected]" | ||
}, | ||
"parent": { | ||
"type": "folder", | ||
"id": "0", | ||
"sequence_id": null, | ||
"etag": null, | ||
"name": "All Files" | ||
}, | ||
"item_status": "active", | ||
"item_collection": { | ||
"total_count": 1, | ||
"entries": [ | ||
{ | ||
"type": "file", | ||
"id": "5000948880", | ||
"sequence_id": "3", | ||
"etag": "3", | ||
"sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc", | ||
"name": "tigers.jpeg" | ||
} | ||
], | ||
"offset": 0, | ||
"limit": 100 | ||
} | ||
} |
Oops, something went wrong.