Пример #1
0
        public async Task UploadAndDownloadFileTest()
        {
            var tokens = new Dictionary <string, string>();
            var files  = Directory.GetFiles(mainDir, "*.cnf", SearchOption.AllDirectories);

            foreach (var f in files)
            {
                Assert.IsTrue(await WebDavClientApi.UploadFileAsync(f, _cts.Token));
                Assert.IsTrue(await WebDavClientApi.IsExistsAsync(f, _cts.Token));
                tokens[await WebDavClientApi.MakeShareableAsync(f, _cts.Token)] = f;
            }

            Assert.AreEqual(files.Length, tokens.Count);

            foreach (var t in tokens.Keys)
            {
                await WebDavClientApi.DownloadFileAsync(t, tokens[t].Replace("WebDavApiTest", "WebDavApiTest_Downloaded"), _cts.Token);

                Assert.IsTrue(File.Exists(tokens[t].Replace("WebDavApiTest", "WebDavApiTest_Downloaded")));
            }

            Assert.IsTrue(await WebDavClientApi.IsExistsAsync(mainDir, _cts.Token));
            Assert.IsTrue(await WebDavClientApi.RemoveFileAsync(mainDir, _cts.Token));
            Assert.IsFalse(await WebDavClientApi.IsExistsAsync(mainDir, _cts.Token));

            Assert.AreEqual(files.Length, Directory.GetFiles(mainDir_Downloaded, "*.cnf", SearchOption.AllDirectories).Length);


            Assert.IsTrue(Directory.Exists(mainDir_Downloaded));
            Directory.Delete(mainDir_Downloaded, true);
            Assert.IsFalse(Directory.Exists(mainDir_Downloaded));
        }
Пример #2
0
 public async Task UploadNonExistedFileTest()
 {
     Assert.IsFalse(await WebDavClientApi.UploadFileAsync(Path.Combine(mainDir, "3110779.cnf"), _cts.Token));
 }