Пример #1
0
        public void Test_StarAFile()
        {
            var request  = new StarFileRequest(FakeToken, FakeRepoId, "/test/file.txt");
            var response = new HttpResponseMessage(HttpStatusCode.Created)
            {
                Content = new StringContent("\"success\"")
            };

            Assert.AreEqual("api2/starredfiles/", request.CommandUri);
            Assert.AreEqual(HttpAccessMethod.Post, request.HttpAccessMethod);

            var webRequest = TestConnection.CreateHttpRequestMessage(DummyServerUri, request);

            Assert.AreEqual(DummyServerUri + "api2/starredfiles/", webRequest.RequestUri.ToString());
            Assert.AreEqual(HttpMethod.Post, webRequest.Method);
            var result = ExecuteSync(() => webRequest.Content.ReadAsStringAsync());

            Assert.IsTrue(result.Contains("repo_id=" + FakeRepoId));
            Assert.IsTrue(result.Contains("p=%2Ftest%2Ffile.txt"));

            Assert.IsTrue(request.WasSuccessful(response));
            Assert.IsTrue(ExecuteSync(() => request.ParseResponseAsync(response)));
        }
Пример #2
0
        /// <summary>
        ///     Add the file to the list of starred files
        /// </summary>
        /// <param name="dirEntry">The file to star</param>
        public async Task <bool> StarFile(SeafDirEntry dirEntry)
        {
            var request = new StarFileRequest(AuthToken, dirEntry.LibraryId, dirEntry.Path);

            return(await _webConnection.SendRequestAsync(ServerUri, request));
        }