public void GetFileMetadata() { mockServer.ExpectNewRequest() .AndExpectUri("https://api.dropbox.com/1/metadata/dropbox/Dir/File.txt?list=false") .AndExpectMethod(HttpMethod.GET) .AndRespondWith(EmbeddedResource("Metadata_File.json"), responseHeaders); MetadataParameters parameters = new MetadataParameters(); parameters.IncludeContents = false; #if NET_4_0 || SILVERLIGHT_5 Entry metadata = dropbox.GetMetadataAsync("Dir/File.txt", parameters).Result; #else Entry metadata = dropbox.GetMetadata("Dir/File.txt", parameters); #endif Assert.AreEqual(230783, metadata.Bytes); Assert.IsNull(metadata.Hash); Assert.AreEqual("page_white_acrobat", metadata.Icon); Assert.AreEqual(false, metadata.IsDeleted); Assert.AreEqual(false, metadata.IsDirectory); Assert.AreEqual("application/pdf", metadata.MimeType); Assert.IsNotNull(metadata.ModifiedDate); Assert.AreEqual("19/07/2011 21:55:38", metadata.ModifiedDate.Value.ToUniversalTime().ToString("dd'/'MM'/'yyyy HH:mm:ss")); Assert.AreEqual("/Getting_Started.pdf", metadata.Path); Assert.AreEqual("35e97029684fe", metadata.Revision); Assert.AreEqual("dropbox", metadata.Root); Assert.AreEqual("225.4KB", metadata.Size); Assert.IsFalse(metadata.ThumbExists); Assert.IsNull(metadata.Contents); }
public void PathNotFound() { mockServer.ExpectNewRequest() .AndExpectUri("https://api.dropbox.com/1/metadata/sandbox/Spring Social/Temp.txt") .AndExpectMethod(HttpMethod.GET) .AndRespondWith("{\"error\": \"Path '/Spring Social/Temp.txt' not found\"}", responseHeaders, HttpStatusCode.NotFound, ""); #if NET_4_0 || SILVERLIGHT_5 dropbox.GetMetadataAsync("/Spring Social/Temp.txt") .ContinueWith(task => { AssertDropboxApiException(task.Exception, "Path '/Spring Social/Temp.txt' not found", DropboxApiError.PathNotFound); }) .Wait(); #else try { dropbox.GetMetadata("/Spring Social/Temp.txt"); Assert.Fail("Exception expected"); } catch (Exception ex) { AssertDropboxApiException(ex, "Path '/Spring Social/Temp.txt' not found", DropboxApiError.PathNotFound); } #endif }