-
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
8 changed files
with
111 additions
and
3 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
34 changes: 34 additions & 0 deletions
34
Box.V2.Test.Integration/Configuration/Commands/NonDisposableCommands/CreateNewFileVersion.cs
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,34 @@ | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Box.V2.Models; | ||
|
||
namespace Box.V2.Test.Integration.Configuration.Commands.DisposableCommands | ||
{ | ||
public class CreateNewFileVersion : CommandBase, INonDisposableCommand | ||
{ | ||
private readonly string _fileName; | ||
private readonly string _filePath; | ||
private readonly string _fileId; | ||
|
||
public string FileId; | ||
public BoxFile File; | ||
|
||
public CreateNewFileVersion(string fileName, string filePath, string fileId, CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) : base(scope, accessLevel) | ||
{ | ||
_fileName = fileName; | ||
_filePath = filePath; | ||
_fileId = fileId; | ||
} | ||
|
||
public async Task<string> Execute(IBoxClient client) | ||
{ | ||
using (var fileStream = new FileStream(_filePath, FileMode.OpenOrCreate)) | ||
{ | ||
var response = await client.FilesManager.UploadNewVersionAsync(_fileName, _fileId, fileStream); | ||
File = response; | ||
FileId = File.Id; | ||
return FileId; | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -298,16 +298,15 @@ public async Task UploadNewVersion_ValidResponse_ValidFile() | |
public async Task ViewVersions_ValidResponse_ValidFileVersions() | ||
{ | ||
/*** Arrange ***/ | ||
var responseString = "{ \"total_count\": 1, \"entries\": [ { \"type\": \"file_version\", \"id\": \"672259576\", \"sha1\": \"359c6c1ed98081b9a69eb3513b9deced59c957f9\", \"name\": \"Dragons.js\", \"size\": 92556, \"created_at\": \"2012-08-20T10:20:30-07:00\", \"modified_at\": \"2012-11-28T13:14:58-08:00\", \"modified_by\": { \"type\": \"user\", \"id\": \"183732129\", \"name\": \"sean rose\", \"login\": \"[email protected]\" } } ] }"; | ||
Handler.Setup(h => h.ExecuteAsync<BoxCollection<BoxFileVersion>>(It.IsAny<IBoxRequest>())) | ||
.Returns(Task.FromResult<IBoxResponse<BoxCollection<BoxFileVersion>>>(new BoxResponse<BoxCollection<BoxFileVersion>>() | ||
{ | ||
Status = ResponseStatus.Success, | ||
ContentString = responseString | ||
ContentString = LoadFixtureFromJson("Fixtures/BoxFiles/ViewVersions200.json") | ||
})); | ||
|
||
/*** Act ***/ | ||
BoxCollection<BoxFileVersion> c = await _filesManager.ViewVersionsAsync("0"); | ||
BoxCollection<BoxFileVersion> c = await _filesManager.ViewVersionsAsync("0", new List<string>() { BoxFileVersion.FieldVersionNumber }); | ||
|
||
/*** Assert ***/ | ||
Assert.AreEqual(c.TotalCount, 1); | ||
|
@@ -324,6 +323,7 @@ public async Task ViewVersions_ValidResponse_ValidFileVersions() | |
Assert.AreEqual("183732129", f.ModifiedBy.Id); | ||
Assert.AreEqual("sean rose", f.ModifiedBy.Name); | ||
Assert.AreEqual("[email protected]", f.ModifiedBy.Login); | ||
Assert.AreEqual("1", f.VersionNumber); | ||
} | ||
|
||
[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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"total_count": 1, | ||
"entries": [ | ||
{ | ||
"type": "file_version", | ||
"id": "672259576", | ||
"sha1": "359c6c1ed98081b9a69eb3513b9deced59c957f9", | ||
"name": "Dragons.js", | ||
"size": 92556, | ||
"created_at": "2012-08-20T10:20:30-07:00", | ||
"modified_at": "2012-11-28T13:14:58-08:00", | ||
"modified_by": { | ||
"type": "user", | ||
"id": "183732129", | ||
"name": "sean rose", | ||
"login": "[email protected]" | ||
}, | ||
"version_number" : "1" | ||
} | ||
] | ||
} |
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