public void Create_Rename_Download_Delete_File() { var fileName = Guid.NewGuid().ToString(); var rnd = new Random(); var data = new byte[50]; rnd.NextBytes(data); var create = _filesApi.CreateFile(fileName, "/SDK_Test_Folder", 50, data); Assert.That(create.Name, Is.EqualTo(fileName)); Assert.That(create.Path, Is.EqualTo("/SDK_Test_Folder")); var newName = Guid.NewGuid().ToString(); var updateFile = new UpdateFile("/SDK_Test_Folder", newName); var update = _filesApi.UpdateFileMetadata(create.Id, updateFile); Assert.That(update.Name, Is.EqualTo(newName)); Assert.That(update.Path, Is.EqualTo("/SDK_Test_Folder")); Assert.That(update.Id, Is.EqualTo(create.Id)); var download = _filesApi.DownloadFile(update.Id); var endData = new byte[50]; download.Read(endData); Assert.That(endData, Is.EqualTo(data)); _filesApi.DeleteFile(update.Id); Assert.Throws <ApiException>(() => _filesApi.GetFile(create.Id)); }
public void List_Folder_Contents() { var rnd = new Random(); var data = new byte[100]; rnd.NextBytes(data); //Create a unique file name var fileName = Guid.NewGuid().ToString(); //Upload a file var upload = _filesApi.CreateFile(fileName, _testFolder, data.Length, data); //List folder contents var contents = _foldersApi.GetFolderContents(_testFolderId); CollectionAssert.Contains(contents.Values.Select(x => x.Name), upload.Name); }
public void Upload_File() { var rnd = new Random(); var data = new byte[100]; rnd.NextBytes(data); //Create a unique file name var fileName = Guid.NewGuid().ToString(); //Upload a file var upload = _filesApi.CreateFile(fileName, _testFolder, data.Length, data); Assert.AreEqual(fileName, upload.Name); }