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 Delete_File() { var rnd = new Random(); var data = new byte[100]; rnd.NextBytes(data); //Create a unique file name var fileName = Guid.NewGuid().ToString(); //Upload file var upload = _filesApi.CreateFile(fileName, _testFolder, data.Length, data); //Delete file _filesApi.DeleteFile(upload.Id); CollectionAssert.IsEmpty(_foldersApi.GetFolderContents(_testFolderId, filter: $"Name eq '{upload.Name}'").Values); }