public async Task SearchAdvanced_LiveSession()
{
const string keyword = "IMG";
//search using an extension that should return results
BoxCollection<BoxItem> results = await _client.SearchManager.SearchAsync(keyword, 200, fileExtensions: new List<string>() { "jpg" });
Assert.AreEqual(12, results.Entries.Count, "Incorrect number of search results using extension");
//search using an extension that should not return results
results = await _client.SearchManager.SearchAsync(keyword, 200, fileExtensions:new List<string>() { "pdf" });
Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using extension");
//search using a created at daterange that should return results
var start = new DateTime(2014, 5, 1);
var end = new DateTime(2014, 5, 30);
results = await _client.SearchManager.SearchAsync(keyword, 200, createdAtRangeFromDate: start, createdAtRangeToDate: end);
Assert.AreEqual(13, results.Entries.Count, "Incorrect number of search results using created at date range");
//search using a created at daterange that should not return results
start = new DateTime(2014, 6, 1);
end = new DateTime(2014, 6, 30);
results = await _client.SearchManager.SearchAsync(keyword, 200, createdAtRangeFromDate: start, createdAtRangeToDate: end);
Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using created at date range");
//search using a updated at daterange that should return results
start = new DateTime(2014, 5, 1);
end = new DateTime(2014, 5, 30);
results = await _client.SearchManager.SearchAsync(keyword, 200, updatedAtRangeFromDate: start, updatedAtRangeToDate: end);
Assert.AreEqual(12, results.Entries.Count, "Incorrect number of search results using updated at date range");
//search using a size range that should return results
var minBytes = 150000;
var maxBytes = 400000;
results = await _client.SearchManager.SearchAsync(keyword, 200, sizeRangeLowerBoundBytes: minBytes, sizeRangeUpperBoundBytes: maxBytes);
Assert.AreEqual(2, results.Entries.Count, "Incorrect number of search results using size range");
//search using a size range that should not return results
minBytes = 40000000;
maxBytes = 50000000;
results = await _client.SearchManager.SearchAsync(keyword, 200, sizeRangeLowerBoundBytes: minBytes, sizeRangeUpperBoundBytes: maxBytes);
Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using size range");
//search using an owner Id that should return results
var ownerId = "215917383";
results = await _client.SearchManager.SearchAsync(keyword, 200, ownerUserIds: new List<string>() { ownerId });
Assert.AreEqual(13, results.Entries.Count, "Incorrect number of search results using owner id");
//search using an owner Id that should not return results
ownerId = "1";
results = await _client.SearchManager.SearchAsync(keyword, 200, ownerUserIds: new List<string>() { ownerId });
Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using owner id");
//search using an ancestor folder Id that should return subset of results
var ancestorFolderId = "1927308583";
results = await _client.SearchManager.SearchAsync(keyword, 200, ancestorFolderIds: new List<string>() { ancestorFolderId });
Assert.AreEqual(6, results.Entries.Count, "Incorrect number of search results using ancestor folder id");
//search using a content type that should return subset of results
var contentType = "file_content";
results = await _client.SearchManager.SearchAsync(keyword, 200, contentTypes: new List<string>() { contentType });
Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using ancestor folder id");
//search using a type that should return files only
var type = "file";
results = await _client.SearchManager.SearchAsync(keyword, 200, type: type);
Assert.AreEqual(12, results.Entries.Count, "Incorrect number of search results using type");
//search using a type that should return folders only
type = "folder";
results = await _client.SearchManager.SearchAsync(keyword, 200, type: type);
Assert.AreEqual(1, results.Entries.Count, "Incorrect number of search results using type");
//search using a type that should return web links only
type = "web_link";
results = await _client.SearchManager.SearchAsync(keyword, 200, type: type);
Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using type");
//search trashed content only
results = await _client.SearchManager.SearchAsync(keyword, 200, trashContent: "trashed_only");
Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using trashed_only");
//search non-trashed content only
results = await _client.SearchManager.SearchAsync(keyword, 200, trashContent: "non_trashed_only");
Assert.AreEqual(13, results.Entries.Count, "Incorrect number of search results using non_trashed_only");
}