public void Test_DeleteDirEntry_Error() { var request = new DeleteDirEntryRequest(FakeToken, FakeRepoId, "/test/subfolder/"); var message = new HttpResponseMessage(HttpStatusCode.BadRequest); Assert.IsFalse(request.WasSuccessful(message)); Assert.AreEqual(SeafErrorCode.PathDoesNotExist, request.GetSeafError(message).SeafErrorCode); }
/// <summary> /// Delete the given file in the given library /// </summary> /// <param name="libraryId">The id of the library the file is in</param> /// <param name="filePath">Path of the file</param> /// <returns>A value which indicates if the deletion was successful</returns> protected async Task <bool> DeleteFile(string libraryId, string filePath) { libraryId.ThrowOnNull(nameof(libraryId)); filePath.ThrowOnNull(nameof(filePath)); var request = new DeleteDirEntryRequest(AuthToken, libraryId, filePath); return(await _webConnection.SendRequestAsync(ServerUri, request)); }
public void Test_DeleteDirEntry_Success() { var request = new DeleteDirEntryRequest(FakeToken, FakeRepoId, "/test/subfolder/"); var message = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("\"success\"") }; Assert.IsTrue(request.WasSuccessful(message)); Assert.IsTrue(ExecuteSync(() => request.ParseResponseAsync(message))); }
public void Test_DeleteDirEntry_HttpRequest() { var request = new DeleteDirEntryRequest(FakeToken, FakeRepoId, "/test/subfolder/"); var httpRequest = TestConnection.CreateHttpRequestMessage(DummyServerUri, request); Assert.AreEqual(HttpMethod.Delete, httpRequest.Method); var uri = httpRequest.RequestUri.ToString(); Assert.IsTrue(uri.StartsWith(DummyServerUri + "api2/repos/" + FakeRepoId + "/dir/?")); // test path parameter Assert.IsTrue(uri.Contains("p=%2Ftest%2Fsubfolder%2F")); }