public void Cannot_Move_File_that_doesnt_Exist( ) { FileInfo localFile = null; string path = null; try { localFile = FileFactory.MakeFile(extension: "txt"); path = this.TestFolder + "/" + string.Format("TestFile{0:yyyyMMddhhmmss}-Move_File.txt", DateTime.Now); } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile.FullName); } try { var moved = this._client.Move(path, path.Replace("TestFile", "MovedFile")).Result; Assert.Fail("Move should have thrown exception"); } catch (AggregateException ae) { ae = ae.Flatten( ); Assert.AreEqual(1, ae.InnerExceptions.Count, "Wrong number of errors returend."); Assert.IsTrue(ae.InnerException is CloudStorageItemNotFoundException, "Did not throw expected exception"); } catch (Exception) { Assert.Fail( ); } }
public void Can_Get_Thumbnail_Small( ) { FileInfo localFile = null; string path = null; try { localFile = FileFactory.MakeImage(ImageFormat.Png); var uploaded = this.ICloudStorageThumbnailProviderClient.UploadFile(this.TestFolder + "/" + string.Format("TestFile{0:yyyyMMddhhmmss}-Thumbnail.png", DateTime.Now), File.OpenRead(localFile.Name)).Result; path = uploaded.Path; } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile.FullName); } var stream = this.ICloudStorageThumbnailProviderClient.GetThumbnail(path, ThumbnailSize.Small).Result; Assert.IsNotNull(stream); using (var file = File.OpenWrite(@"C:\Temp\test.png")) { stream.CopyTo(file); } var fi = new FileInfo(@"C:\Temp\test.png"); Assert.IsTrue(fi.Length > 0); try { var deleted = this.ICloudStorageThumbnailProviderClient.Delete(path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Chunk_Upload_File( ) { FileInfo localFile = null; try { localFile = FileFactory.MakeFile(length: 10485760); } catch { Assert.Inconclusive("Couldn't make file"); } var data = File.ReadAllBytes(localFile.Name); var chunks = data.Split(10).ToList( ); var chunk = this.dropboxClient.StartChunkedUpload(chunks.First( ).ToArray( )).Result; for (var i = 1; i < chunks.Count( ); i++) { chunk = this.dropboxClient.AppendChunkedUpload(chunk, chunks[i].ToArray( )).Result; } var chunked = this.dropboxClient.CommitChunkedUpload(chunk, localFile.Name).Result; Assert.IsNotNull(chunked); try { File.Delete(localFile.FullName); var deleted = this.dropboxClient.Delete(chunked.Path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Create_CopyRef( ) { FileInfo localFile = null; string path = null; try { localFile = FileFactory.MakeFile(extension: "txt"); var uploaded = this.dropboxClient.UploadFile(this.TestFolder + "/" + string.Format("TestFile{0:yyyyMMddhhmmss}-Create_CopyRef.txt", DateTime.Now), File.OpenRead(localFile.Name)).Result; path = uploaded.Path; } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile.FullName); } var copyRef = this.dropboxClient.GetCopyRef(path).Result; Assert.IsNotNull(copyRef); try { var deletedCopy = this.dropboxClient.Delete(path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Get_MetaData_File_With_Special_Char( ) { FileInfo localFile = null; string path = null; try { localFile = FileFactory.MakeFile(extension: "txt"); var uploaded = this._client.UploadFile(this.TestFolder + "/&Getting'Started.rtf", File.OpenRead(localFile.Name)).Result; path = uploaded.Path; } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile.FullName); } var metaData = this._client.GetMetaData(path).Result; this.AssertIsFile(metaData, path); try { var deleted = this._client.Delete(path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Get_Media( ) { FileInfo localFile = null; string path = null; try { localFile = FileFactory.MakeFile(extension: "mp4"); var uploaded = this.dropboxClient.UploadFile(this.TestFolder + "/" + string.Format("TestFile{0:yyyyMMddhhmmss}-Media.mp4", DateTime.Now), File.OpenRead(localFile.Name)).Result; path = uploaded.Path; } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile.FullName); } var mediaLink = this.dropboxClient.GetMedia(path).Result; Assert.IsNotNull(mediaLink); Assert.IsNotNull(mediaLink.Expires); Assert.IsNotNull(mediaLink.Url); try { var deleted = this.dropboxClient.Delete(path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Get_File_And_Save( ) { FileInfo localFile = null; string path = null; try { localFile = FileFactory.MakeFile(extension: "txt"); var uploaded = this._client.UploadFile(this.TestFolder + "/" + localFile.Name, File.OpenRead(localFile.Name)).Result; path = uploaded.Path; } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile.FullName); } var stream = this._client.GetFile(path).Result; Assert.IsNotNull(stream); using (var file = File.OpenWrite(@"C:\Temp\" + localFile.Name)) { stream.CopyTo(file); } var fi = new FileInfo(@"C:\Temp\" + localFile.Name); Assert.IsTrue(fi.Length > 0); try { var deleted = this._client.Delete(path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Move_File( ) { FileInfo localFile = null; string path = null; try { localFile = FileFactory.MakeFile(extension: "txt"); var uploaded = this._client.UploadFile(this.TestFolder + "/" + string.Format("TestFile{0:yyyyMMddhhmmss}-Move_File.txt", DateTime.Now), File.OpenRead(localFile.Name)).Result; path = uploaded.Path; } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile.FullName); } var moved = this._client.Move(path, path.Replace("TestFile", "MovedFile")).Result; Assert.IsNotNull(moved); try { var deletedCopy = this._client.Delete(moved.Path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Make_Many_Requests( ) { FileInfo localFile = null; string path = null; try { localFile = FileFactory.MakeFile(extension: "txt"); var uploaded = this._client.UploadFile(this.TestFolder + "/" + localFile.Name, File.OpenRead(localFile.Name)).Result; path = uploaded.Path; } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile.FullName); } for (var i = 0; i < 10; i++) { var metaData = this._client.GetMetaData(path).Result; Assert.IsNotNull(metaData); } try { var deleted = this._client.Delete(path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Copy_File_With_Space( ) { FileInfo localFile = null; string path = null; try { localFile = FileFactory.MakeFile(extension: "txt"); var uploaded = this._client.UploadFile(this.TestFolder + "/" + string.Format("TestFile{0:yyyyMMddhhmmss}-Copy File.txt", DateTime.Now), File.OpenRead(localFile.Name)).Result; path = uploaded.Path; } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile.FullName); } var copied = this._client.Copy(path, path.Replace("TestFile", "CopyFile")).Result; Assert.IsNotNull(copied); Assert.AreEqual(path.Replace("TestFile", "CopyFile"), copied.Path, "File not uploaded to correct location"); try { var deletedOrg = this._client.Delete(path).Result; var deletedCopy = this._client.Delete(copied.Path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Upload_File_Over_Existing_File( ) { FileInfo localFile1 = null; FileInfo localFile2 = null; string path = null; try { localFile1 = FileFactory.MakeFile(extension: "txt"); var firstUpload = this._client.UploadFile(this.TestFolder + "/" + localFile1.Name, File.OpenRead(localFile1.Name)).Result; path = firstUpload.Path; localFile2 = FileFactory.MakeFile(extension: "txt"); } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile1.FullName); } var uploaded = this._client.UploadFile(path, File.OpenRead(localFile2.Name)).Result; Assert.IsNotNull(uploaded); Assert.AreEqual(path, uploaded.Path, "File not uploaded to correct location"); try { File.Delete(localFile2.FullName); var deleted = this._client.Delete(uploaded.Path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Delete_File_With_Special_Char( ) { FileInfo localFile = null; string path = null; try { localFile = FileFactory.MakeFile(extension: "txt"); var uploaded = this._client.UploadFile(this.TestFolder + "/" + "test&file's.txt", File.OpenRead(localFile.Name)).Result; path = uploaded.Path; } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile.FullName); } var deleted = this._client.Delete(path).Result; Assert.IsNotNull(deleted); }
public void Can_Upload_File_With_International_Char( ) { FileInfo localFile = null; try { localFile = FileFactory.MakeFile(extension: "txt"); } catch { Assert.Inconclusive("Couldn't make file"); } var uploaded = this._client.UploadFile(this.TestFolder + "/testПр.txt", File.ReadAllBytes(localFile.Name)).Result; Assert.IsNotNull(uploaded); Assert.AreEqual(this.TestFolder + "/testПр.txt", uploaded.Path, "File not uploaded to correct location"); try { File.Delete(localFile.FullName); var deleted = this._client.Delete(uploaded.Path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Upload_1MB_File( ) { FileInfo localFile = null; try { localFile = FileFactory.MakeFile(length: 1048576); } catch { Assert.Inconclusive("Couldn't make file"); } var uploaded = this._client.UploadFile(this.TestFolder + "/" + localFile.Name, File.OpenRead(localFile.Name)).Result; Assert.IsNotNull(uploaded); Assert.AreEqual(this.TestFolder + "/" + localFile.Name, uploaded.Path, "File not uploaded to correct location"); try { File.Delete(localFile.FullName); var deleted = this._client.Delete(uploaded.Path).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Upload_File_To_New_Folder( ) { FileInfo localFile = null; string newFolderName = Guid.NewGuid( ).ToString( ); try { localFile = FileFactory.MakeFile(extension: "txt"); } catch { Assert.Inconclusive("Couldn't make file"); } var uploaded = this._client.UploadFile(string.Format("{0}/{1}/{2}", this.TestFolder, newFolderName, localFile.Name), File.OpenRead(localFile.Name)).Result; Assert.IsNotNull(uploaded); Assert.AreEqual(string.Format("{0}/{1}/{2}", this.TestFolder, newFolderName, localFile.Name), uploaded.Path, "File not uploaded to correct location"); try { File.Delete(localFile.FullName); var deleted = this._client.Delete(string.Format("{0}/{1}", this.TestFolder, newFolderName)).Result; } catch { Assert.Inconclusive("Couldn't clean up files"); } }
public void Can_Shares_Long( ) { string path = null; try { var localFile = FileFactory.MakeFile( ); var uploaded = this.dropboxClient.UploadFile(this.TestFolder + "/" + localFile.Name, File.OpenRead(localFile.Name)).Result; path = uploaded.Path; } catch { Assert.Inconclusive("Couldn't make file"); } var shareResponse = this.dropboxClient.GetShare(path, false).Result; Assert.IsNotNull(shareResponse); Assert.IsNotNull(shareResponse.Url); try { var deleted = this.dropboxClient.Delete(path).Result; } catch { Assert.Inconclusive("Couldn't clean up file"); } }
public void Cannot_Get_Thumbnail_that_doesnt_Exist( ) { FileInfo localFile = null; string path = null; try { localFile = FileFactory.MakeFile(extension: "txt"); path = this.TestFolder + "/" + localFile.Name; } catch { Assert.Inconclusive("Couldn't make file"); } finally { File.Delete(localFile.FullName); } try { var stream = this.ICloudStorageThumbnailProviderClient.GetThumbnail(path).Result; Assert.Fail("Get should have thrown exception"); } catch (AggregateException ae) { Assert.AreEqual(1, ae.InnerExceptions.Count, "Wrong number of errors returend."); Assert.IsTrue(ae.InnerException is CloudStorageItemNotFoundException, "Did not throw expected exception"); } catch (Exception) { Assert.Fail( ); } }