Esempio n. 1
0
        public void GetItemsTest()
        {
            var api = new MailRuCloud();

            api.Account = this.account;
            var items = api.GetItems("/Camera Uploads/");

            Assert.IsNotNull(items);
            Assert.IsTrue(items.Files.Count == items.NumberOfFiles || items.Folders.Count == items.NumberOfFolders);

            var percent = 0;

            api.ChangingProgressEvent += delegate(object sender, ProgressChangedEventArgs e)
            {
                percent = e.ProgressPercentage;
            };

            var fileToDownload = items.Files.First(t => t.Size <= 1 * 1024 * 1024);
            var task           = api.GetFileAsync(fileToDownload);

            Assert.IsNotNull(task.Result);
            Assert.IsTrue(percent == 100);

            percent = 0;
            var task2 = api.GetFileAsync(fileToDownload, @"C:\Development\MailRuCloudApi\");

            Assert.IsTrue(task2.Result);
            Assert.IsTrue(percent == 100);

            var fileInfo = new FileInfo(@"C:\Development\MailRuCloudApi\" + fileToDownload.Name);

            Assert.IsTrue(fileInfo.Exists, "File is not created.");
            Assert.IsTrue(fileInfo.Length > 0, "File size in not retrieved.");
        }