Skip to content

Commit

Permalink
feat!: remove deprecated methods (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwwoda authored Dec 12, 2022
1 parent ab45a79 commit 70f7a89
Show file tree
Hide file tree
Showing 30 changed files with 187 additions and 804 deletions.
4 changes: 2 additions & 2 deletions Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ await Retry(async () =>

[TestMethod]
[ExpectedException(typeof(TimeoutException))]
public async Task DownloadStreamAsync_ForTimeoutShorterThanDownloadTime_ShouldAbortDownload()
public async Task DownloadAsync_ForTimeoutShorterThanDownloadTime_ShouldAbortDownload()
{
var uploadedFile = await CreateSmallFile(FolderId);
var timeout = new TimeSpan(0, 0, 0, 0, 1);

await UserClient.FilesManager.DownloadStreamAsync(uploadedFile.Id, timeout: timeout);
await UserClient.FilesManager.DownloadAsync(uploadedFile.Id, timeout: timeout);
}

[TestMethod]
Expand Down
2 changes: 1 addition & 1 deletion Box.V2.Test.Integration/BoxSearchManagerIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public async Task SearchAsync_ForNonExistentKeyword_ShouldReturnNoResults()
{
const string Keyword = "NonExistentKeyWord";

BoxCollection<BoxItem> results = await UserClient.SearchManager.SearchAsync(Keyword, 200);
BoxCollection<BoxItem> results = await UserClient.SearchManager.QueryAsync(Keyword, limit: 200);

Assert.IsNotNull(results);
Assert.AreEqual(0, results.Entries.Count);
Expand Down
1 change: 0 additions & 1 deletion Box.V2.Test/BoxCCGAuthTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public BoxCCGAuthTest()
_boxConfig.SetupGet(x => x.ClientId).Returns("123");
_boxConfig.SetupGet(x => x.ClientSecret).Returns("SECRET");
_boxConfig.SetupGet(x => x.BoxApiHostUri).Returns(new Uri(Constants.BoxApiHostUriString));
_boxConfig.SetupGet(x => x.BoxAuthTokenApiUri).Returns(new Uri(Constants.BoxAuthTokenApiUriString));
_ccgAuth = new BoxCCGAuth(_boxConfig.Object, _service);
}

Expand Down
18 changes: 2 additions & 16 deletions Box.V2.Test/BoxConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public void BoxConfig_SetUriString()

var exampleUri = new Uri("https://example.com/");
config = BoxConfigBuilder.CreateFromJsonString(JsonString)
.SetBoxApiUri(exampleUri)
.SetBoxApiHostUri(exampleUri)
.Build();
Assert.AreEqual(config.BoxApiUri, exampleUri);
Assert.AreEqual(config.BoxApiUri, exampleUri + "2.0/");
}

[TestMethod]
Expand Down Expand Up @@ -63,20 +63,6 @@ public void BoxConfig_CreateFromString()
Assert.AreEqual(config.EnterpriseId, "eid-123");
}

[TestMethod]
public void BoxConfig_SetAuthTokenUriString()
{
var boxConfig = new BoxConfigBuilder("", "")
.Build();
Assert.AreEqual(boxConfig.BoxAuthTokenApiUri, new Uri(Constants.BoxAuthTokenApiUriString));

var exampleUri = new Uri("https://example.com/token");
var newConfig = new BoxConfigBuilder("", "")
.SetBoxTokenApiUri(exampleUri)
.Build();
Assert.AreEqual(newConfig.BoxAuthTokenApiUri.ToString(), exampleUri + "/");
}

[TestMethod]
public void BoxConfig_SetBoxApiHostUri()
{
Expand Down
37 changes: 0 additions & 37 deletions Box.V2.Test/BoxFilesManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -833,43 +833,6 @@ public async Task DeleteFile_ErrorResponse_Exception()
}
}

[TestMethod]
public async Task DownloadStream_ValidResponse_ValidStream()
{

using (var exampleFile = new FileStream(string.Format(GetSaveFolderPath(), "example.png"), FileMode.OpenOrCreate))
{
/*** Arrange ***/
var location = new Uri("http://dl.boxcloud.com");
var headers = new HttpResponseMessage().Headers;
headers.Location = location;
Handler.Setup(h => h.ExecuteAsync<BoxFile>(It.IsAny<IBoxRequest>()))
.Returns(Task.FromResult<IBoxResponse<BoxFile>>(new BoxResponse<BoxFile>()
{
Status = ResponseStatus.Success,
Headers = headers

}));
IBoxRequest boxRequest = null;
Handler.Setup(h => h.ExecuteAsync<Stream>(It.IsAny<IBoxRequest>()))
.Returns(Task.FromResult<IBoxResponse<Stream>>(new BoxResponse<Stream>()
{
Status = ResponseStatus.Success,
ResponseObject = exampleFile

}))
.Callback<IBoxRequest>(r => boxRequest = r); ;

/*** Act ***/
Stream result = await _filesManager.DownloadStreamAsync("34122832467");

/*** Assert ***/

Assert.IsNotNull(result, "Stream is Null");

}
}

[TestMethod]
public async Task Download_LargeOffset_ValidStream()
{
Expand Down
56 changes: 1 addition & 55 deletions Box.V2.Test/BoxFoldersManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,60 +75,6 @@ public async Task GetFolderItems_ValidResponse_SortDirection()
Assert.AreEqual("DESC", boxRequest.Parameters["direction"]);
}

[TestMethod]
public async Task GetFolder_ValidResponse_ValidFolder()
{
Handler.Setup(h => h.ExecuteAsync<BoxFolder>(It.IsAny<IBoxRequest>()))
.Returns(() => Task.FromResult<IBoxResponse<BoxFolder>>(new BoxResponse<BoxFolder>()
{
Status = ResponseStatus.Success,
ContentString = "{ \"type\":\"folder\", \"id\":\"0\", \"sequence_id\":null, \"etag\":null, \"name\":\"All Files\", \"created_at\":null, \"modified_at\":null, \"description\":\"\", \"size\":61591428468, \"path_collection\":{ \"total_count\":0, \"entries\":[ ] }, \"created_by\":{ \"type\":\"user\", \"id\":\"189912110\", \"name\":\"Brian\", \"login\":\"[email protected]\" }, \"modified_by\":{ \"type\":\"user\", \"id\":\"189912110\", \"name\":\"Brian\", \"login\":\"[email protected]\" }, \"trashed_at\":null, \"purged_at\":null, \"content_created_at\":null, \"content_modified_at\":null, \"owned_by\":{ \"type\":\"user\", \"id\":\"189912110\", \"name\":\"Brian\", \"login\":\"[email protected]\" }, \"shared_link\":null, \"folder_upload_email\":null, \"parent\":null, \"item_status\":\"active\", \"item_collection\":{ \"total_count\":10, \"entries\":[ { \"type\":\"folder\", \"id\":\"766352168\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Books\" }, { \"type\":\"folder\", \"id\":\"869883498\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"bytLabs\" }, { \"type\":\"folder\", \"id\":\"767221958\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Games\" }, { \"type\":\"folder\", \"id\":\"766174084\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Mixes\" }, { \"type\":\"folder\", \"id\":\"57181304\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Muzik\" }, { \"type\":\"folder\", \"id\":\"857305570\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"My\" }, { \"type\":\"folder\", \"id\":\"627316229\", \"sequence_id\":\"1\", \"etag\":\"1\", \"name\":\"My Music Folder\" }, { \"type\":\"folder\", \"id\":\"860155462\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"sample\" }, { \"type\":\"folder\", \"id\":\"775829294\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Software\" }, { \"type\":\"folder\", \"id\":\"811565831\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Test\" } ], \"offset\":0, \"limit\":10, \"order\":[ { \"by\":\"type\", \"direction\":\"ASC\" }, { \"by\":\"name\", \"direction\":\"ASC\" } ] } }"
}));

BoxFolder f = await _foldersManager.GetItemsAsync("0", 10);

Assert.AreEqual(f.Id, "0");
Assert.AreEqual(f.Type, "folder");
Assert.IsNull(f.SequenceId);
Assert.IsNull(f.ETag);
Assert.IsNull(f.CreatedAt);
Assert.IsNull(f.ModifiedAt);
Assert.AreEqual(f.Description, "");
Assert.AreEqual(f.Size, 61591428468);
Assert.AreEqual(f.PathCollection.TotalCount, 0);
Assert.AreEqual(f.PathCollection.Entries.Count, 0);
Assert.AreEqual(f.CreatedBy.Type, "user");
Assert.AreEqual(f.CreatedBy.Id, "189912110");
Assert.AreEqual(f.CreatedBy.Name, "Brian");
Assert.AreEqual(f.CreatedBy.Login, "[email protected]");
Assert.AreEqual(f.ModifiedBy.Type, "user");
Assert.AreEqual(f.ModifiedBy.Id, "189912110");
Assert.AreEqual(f.ModifiedBy.Name, "Brian");
Assert.AreEqual(f.ModifiedBy.Login, "[email protected]");
//Assert.IsNull(f.TrashedAt); // Need to add property
//Assert.IsNull(f.PurgedAt); // Need to add property
//Assert.IsNull(f.ContentCreatedAt); // Need to add property
//Assert.IsNull(f.ContentModifiedAt); // Need to add property
Assert.AreEqual(f.OwnedBy.Type, "user");
Assert.AreEqual(f.OwnedBy.Id, "189912110");
Assert.AreEqual(f.OwnedBy.Name, "Brian");
Assert.AreEqual(f.OwnedBy.Login, "[email protected]");
Assert.IsNull(f.SharedLink);
Assert.IsNull(f.FolderUploadEmail);
Assert.IsNull(f.Parent);
Assert.AreEqual(f.ItemStatus, "active");
Assert.AreEqual(f.Id, "0");
Assert.AreEqual(f.Name, "All Files");
Assert.AreEqual(f.ModifiedBy.Id, "189912110");
Assert.AreEqual(f.ItemCollection.TotalCount, 10);
Assert.AreEqual(f.ItemCollection.Entries.Count, 10);
//Assert.AreEqual(f.Offset, "0"); // Need to add property
//Assert.AreEqual(f.Order[0].By, "type"); // Need to add property
//Assert.AreEqual(f.Order[0].Direction, "ASC"); // Need to add property
//Assert.AreEqual(f.Order[1].By, "name"); // Need to add property
//Assert.AreEqual(f.Order[1].Direction, "ASC"); // Need to add property
}

[TestMethod]
public async Task CreateFolder_ValidResponse_ValidFolder()
{
Expand Down Expand Up @@ -707,7 +653,7 @@ public async Task GetTrashedItems_ValidResponse_ValidFiles()
}));

/*** Act ***/
BoxCollection<BoxItem> i = await _foldersManager.GetTrashItemsAsync("fakeId", 10);
BoxCollection<BoxItem> i = await _foldersManager.GetTrashItemsAsync(10);
BoxItem i1 = i.Entries.FirstOrDefault();
BoxItem i2 = i.Entries.Skip(1).FirstOrDefault();

Expand Down
59 changes: 0 additions & 59 deletions Box.V2.Test/BoxMetadataManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -554,65 +554,6 @@ public async Task SetFolderMetadataAsync_Create_Error()
}
}

[TestMethod]
public async Task ExecuteMetadataQuery_ValidResponse()
{
/*** Arrange ***/
IBoxRequest boxRequest = null;
Handler.Setup(h => h.ExecuteAsync<BoxCollectionMarkerBased<BoxMetadataQueryItem>>(It.IsAny<IBoxRequest>()))
.Returns(Task.FromResult<IBoxResponse<BoxCollectionMarkerBased<BoxMetadataQueryItem>>>(new BoxResponse<BoxCollectionMarkerBased<BoxMetadataQueryItem>>()
{
Status = ResponseStatus.Success,
ContentString = LoadFixtureFromJson("Fixtures/BoxMetadata/ExecuteMetadataQuery200.json")
}))
.Callback<IBoxRequest>(r => boxRequest = r);

/*** Act ***/
var queryParams = new Dictionary<string, object>
{
{ "arg", 100 }
};
var orderByList = new List<BoxMetadataQueryOrderBy>();
var orderBy = new BoxMetadataQueryOrderBy()
{
FieldKey = "amount",
Direction = BoxSortDirection.ASC
};
orderByList.Add(orderBy);
var marker = "q3f87oqf3qygou5t478g9gwrbul";
BoxCollectionMarkerBased<BoxMetadataQueryItem> items = await _metadataManager.ExecuteMetadataQueryAsync(from: "enterprise_123456.someTemplate", query: "amount >= :arg", queryParameters: queryParams, ancestorFolderId: "5555", indexName: "amountAsc", orderBy: orderByList, marker: marker, autoPaginate: false);
/*** Assert ***/

// Request check
Assert.IsNotNull(boxRequest);
Assert.AreEqual(RequestMethod.Post, boxRequest.Method);
Assert.AreEqual(MetadataQueryUri, boxRequest.AbsoluteUri.AbsoluteUri);
var payload = JObject.Parse(boxRequest.Payload);
Assert.AreEqual("enterprise_123456.someTemplate", payload["from"]);
Assert.AreEqual("amount >= :arg", payload["query"]);
Assert.AreEqual(100, payload["query_params"]["arg"]);
Assert.AreEqual("5555", payload["ancestor_folder_id"]);
var payloadOrderBy = JArray.Parse(payload["order_by"].ToString());
Assert.AreEqual("amount", payloadOrderBy[0]["field_key"]);
Assert.AreEqual("ASC", payloadOrderBy[0]["direction"]);
Assert.AreEqual(marker, payload["marker"]);

// Response check
Assert.AreEqual(items.Entries[0].Item.Type, "file");
Assert.AreEqual(items.Entries[0].Item.Id, "1617554169109");
Assert.AreEqual(items.Entries[0].Item.Name, "My Contract.docx");
Assert.AreEqual(items.Entries[0].Item.SequenceId, "0");
Assert.AreEqual(items.Entries[0].Item.CreatedBy.Type, "user");
Assert.AreEqual(items.Entries[0].Item.CreatedBy.Login, "[email protected]");
Assert.AreEqual(items.Entries[0].Item.Parent.Id, "16125613433");
Assert.AreEqual(items.NextMarker, "AAAAAmVYB1FWec8GH6yWu2nwmanfMh07IyYInaa7DZDYjgO1H4KoLW29vPlLY173OKsci6h6xGh61gG73gnaxoS+o0BbI1/h6le6cikjlupVhASwJ2Cj0tOD9wlnrUMHHw3/ISf+uuACzrOMhN6d5fYrbidPzS6MdhJOejuYlvsg4tcBYzjauP3+VU51p77HFAIuObnJT0ff");
var metadata = JObject.FromObject(items.Entries[0].Metadata["enterprise_123456"]);
Assert.AreEqual(metadata["someTemplate"]["$parent"], "file_161753469109");
Assert.AreEqual(metadata["someTemplate"]["customerName"], "Phoenix Corp");
Assert.AreEqual(metadata["someTemplate"]["$typeVersion"], 0);
Assert.AreEqual(metadata["someTemplate"]["region"], "West");
}

[TestMethod]
public async Task ExecuteMetadataQueryWithoutUseIndexWithFields_ValidResponse()
{
Expand Down
50 changes: 1 addition & 49 deletions Box.V2.Test/BoxSearchManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,62 +33,14 @@ public async Task SearchKeyword_ValidResponse_ValidResults()
.Callback<IBoxRequest>(r => boxRequest = r);

/*** Act ***/
BoxCollection<BoxItem> results = await SearchManager.SearchAsync("fakeKeyword", 10, sort: "modified_at", direction: BoxSortDirection.ASC);
BoxCollection<BoxItem> results = await SearchManager.QueryAsync("fakeKeyword", limit: 10, sort: "modified_at", direction: BoxSortDirection.ASC);
var queryParams = boxRequest.Parameters;
/*** Assert ***/
Assert.AreEqual(4, results.TotalCount);
Assert.AreEqual("modified_at", queryParams["sort"]);
Assert.AreEqual("ASC", queryParams["direction"]);
}

[TestMethod]
public async Task SearchWithDateRanges_ValidResponse_ValidResults()
{
/*** Arrange ***/
var responseString = "{\"total_count\":4,\"entries\":[{\"type\":\"file\",\"id\":\"1874102965\",\"sequence_id\":\"0\",\"etag\":\"0\",\"sha1\":\"63a112a4567fb556f5269735102a2f24f2cbea56\",\"name\":\"football.jpg\",\"description\":\"\",\"size\":260271,\"path_collection\":{\"total_count\":1,\"entries\":[{\"type\":\"folder\",\"id\":\"0\",\"sequence_id\":null,\"etag\":null,\"name\":\"All Files\"}]},\"created_at\":\"2012-03-22T18:25:07-07:00\",\"modified_at\":\"2012-10-25T14:40:05-07:00\",\"created_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"[email protected]\"},\"modified_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"[email protected]\"},\"owned_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"[email protected]\"},\"shared_link\":null,\"parent\":{\"type\":\"folder\",\"id\":\"0\",\"sequence_id\":null,\"etag\":null,\"name\":\"All Files\"},\"item_status\":\"active\", \"sort\":\"modified_at\", \"direction\":\"ASC\"}],\"offset\":0,\"limit\":1}";
IBoxRequest boxRequest = null;

Handler.Setup(h => h.ExecuteAsync<BoxCollection<BoxItem>>(It.IsAny<IBoxRequest>()))
.Returns(Task.FromResult<IBoxResponse<BoxCollection<BoxItem>>>(new BoxResponse<BoxCollection<BoxItem>>()
{
Status = ResponseStatus.Success,
ContentString = responseString
}))
.Callback<IBoxRequest>(r => boxRequest = r);

/*** Act ***/
var startDate = new DateTimeOffset(1988, 11, 18, 9, 30, 0, TimeSpan.Zero);
var endDate = new DateTimeOffset(2018, 11, 18, 9, 30, 0, TimeSpan.Zero);
var results = await SearchManager.SearchAsync("test", createdAtRangeFromDate: startDate, createdAtRangeToDate: endDate, updatedAtRangeFromDate: startDate, updatedAtRangeToDate: endDate);

/*** Assert ***/
Assert.AreEqual("query=test&created_at_range=1988-11-18T09%3A30%3A00%2B00%3A00%2C2018-11-18T09%3A30%3A00%2B00%3A00&updated_at_range=1988-11-18T09%3A30%3A00%2B00%3A00%2C2018-11-18T09%3A30%3A00%2B00%3A00&limit=30&offset=0", boxRequest.GetQueryString());
}

[TestMethod]
public async Task SearchWithOpenDateRanges_ValidResponse_ValidResults()
{
/*** Arrange ***/
var responseString = "{\"total_count\":4,\"entries\":[{\"type\":\"file\",\"id\":\"1874102965\",\"sequence_id\":\"0\",\"etag\":\"0\",\"sha1\":\"63a112a4567fb556f5269735102a2f24f2cbea56\",\"name\":\"football.jpg\",\"description\":\"\",\"size\":260271,\"path_collection\":{\"total_count\":1,\"entries\":[{\"type\":\"folder\",\"id\":\"0\",\"sequence_id\":null,\"etag\":null,\"name\":\"All Files\"}]},\"created_at\":\"2012-03-22T18:25:07-07:00\",\"modified_at\":\"2012-10-25T14:40:05-07:00\",\"created_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"[email protected]\"},\"modified_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"[email protected]\"},\"owned_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"[email protected]\"},\"shared_link\":null,\"parent\":{\"type\":\"folder\",\"id\":\"0\",\"sequence_id\":null,\"etag\":null,\"name\":\"All Files\"},\"item_status\":\"active\", \"sort\":\"modified_at\", \"direction\":\"ASC\"}],\"offset\":0,\"limit\":1}";
IBoxRequest boxRequest = null;

Handler.Setup(h => h.ExecuteAsync<BoxCollection<BoxItem>>(It.IsAny<IBoxRequest>()))
.Returns(Task.FromResult<IBoxResponse<BoxCollection<BoxItem>>>(new BoxResponse<BoxCollection<BoxItem>>()
{
Status = ResponseStatus.Success,
ContentString = responseString
}))
.Callback<IBoxRequest>(r => boxRequest = r);

/*** Act ***/
var startDate = new DateTimeOffset(1988, 11, 18, 9, 30, 0, TimeSpan.Zero);
var endDate = new DateTimeOffset(2018, 11, 18, 9, 30, 0, TimeSpan.Zero);
var results = await SearchManager.SearchAsync("test", createdAtRangeFromDate: startDate, updatedAtRangeToDate: endDate);

/*** Assert ***/
Assert.AreEqual("query=test&created_at_range=1988-11-18T09%3A30%3A00%2B00%3A00%2C&updated_at_range=%2C2018-11-18T09%3A30%3A00%2B00%3A00&limit=30&offset=0", boxRequest.GetQueryString());
}

[TestMethod]
public async Task Query_ValidResponse_ValidResults()
{
Expand Down
Loading

0 comments on commit 70f7a89

Please sign in to comment.