public void Test_GetFileDetail_Success() { var request = new GetFileDetailRequest(FakeToken, FakeRepoId, "/test/subfolder/foo.py"); var message = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(@"{ ""id"": ""013d3d38fed38b3e8e26b21bb3463eab6831194f"", ""mtime"": 1398148877, ""type"": ""file"", ""name"": ""foo.py"", ""size"": 22 }]") }; Assert.IsTrue(request.WasSuccessful(message)); var result = ExecuteSync(() => request.ParseResponseAsync(message)); Assert.AreEqual("foo.py", result.Name); Assert.AreEqual(FakeRepoId, result.LibraryId); Assert.AreEqual("/test/subfolder/foo.py", result.Path); Assert.AreEqual("013d3d38fed38b3e8e26b21bb3463eab6831194f", result.Id); Assert.AreEqual(DirEntryType.File, result.Type); Assert.AreEqual(22, result.Size); // converted the timestamp 1398148877 using http://www.onlineconversion.com/unix_time.htm // note: comparison is done in local time Assert.AreEqual(DateTime.Parse("Tue, 22 Apr 2014 06:41:17 GMT", CultureInfo.InvariantCulture), result.Timestamp); }
/// <summary> /// Retrieve information about the given file in the given library /// </summary> /// <param name="libraryId">The id of the library the file belongs to</param> /// <param name="filePath">Path to the file</param> /// <returns>The directory entry of the file</returns> public async Task <SeafDirEntry> GetFileDetail(string libraryId, string filePath) { libraryId.ThrowOnNull(nameof(libraryId)); filePath.ThrowOnNull(nameof(filePath)); var request = new GetFileDetailRequest(AuthToken, libraryId, filePath); return(await _webConnection.SendRequestAsync(ServerUri, request)); }