Beispiel #1
0
        public void Move_Folder()
        {
            //Create a unique folder name
            var folderName1 = Guid.NewGuid().ToString();

            var rnd  = new Random();
            var data = new byte[100];

            rnd.NextBytes(data);

            //Create a unique file name
            var fileName = Guid.NewGuid().ToString();

            //Create a folder
            var createFolder1 = new CreateFolder(_testFolder, folderName1);
            var folder1       = _foldersApi.CreateFolder(createFolder1);

            //Upload a file
            var file = _filesApi.CreateFile(fileName, _testFolder + "/" + folderName1, data.Length, data);

            //Create another unique folder name
            var folderName2 = Guid.NewGuid().ToString();

            //Create another folder
            var createFolder2 = new CreateFolder(_testFolder, folderName2);

            _foldersApi.CreateFolder(createFolder2);

            //Move folder and file
            var folderUpdate  = new UpdateFolder(_testFolder + "/" + folderName2, folderName1);
            var updatedFolder = _foldersApi.UpdateFolder(folder1.Id, folderUpdate);

            Assert.AreEqual(updatedFolder.Path + "/" + updatedFolder.Name, _filesApi.GetFile(file.Id).Path);
            Assert.AreNotEqual(file.Path, _filesApi.GetFile(file.Id).Path);
        }
        public void Copy_File()
        {
            var rnd   = new Random();
            var data1 = new byte[100];

            rnd.NextBytes(data1);

            //Create a unique file name
            var fileName1 = Guid.NewGuid().ToString();

            //Create a unique folder name
            var folderName = Guid.NewGuid().ToString();

            //Upload a file
            var upload = _filesApi.CreateFile(fileName1, _testFolder, data1.Length, data1);

            //Create a folder
            var createFolder = new CreateFolder(_testFolder, folderName);

            var folder = _foldersApi.CreateFolder(createFolder);

            //Move files to folder
            var movedFile = _foldersApi.MoveFolder(folder.Id, new List <string> {
                upload.Id
            }, deleteSource: false);

            CollectionAssert.Contains(movedFile.Values.Select(x => x.Name), upload.Name);
            Assert.AreEqual(upload.Name, _filesApi.GetFile(upload.Id).Name);
        }
        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));
        }