using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class NetworkAgentTest
{
[Test]
- public void TestUpload()
+ public async void TestUpload()
{
var agent = new NetworkAgent();
client.DeleteObject(null, FolderConstants.PithosContainer, fileName);
- var task = Signature.CalculateTreeHashAsync(filePath, accountInfo.BlockSize, accountInfo.BlockHash);
+ var treeHash = await Signature.CalculateTreeHashAsync(filePath, accountInfo.BlockSize, accountInfo.BlockHash, 2);
var cloudFile = new ObjectInfo {Account = account, Container = "pithos"};
var fileInfo = new FileInfo(filePath);
- var tasks=agent.UploadWithHashMap(accountInfo,cloudFile,fileInfo,fileName,task);
- Task.Factory.Iterate(tasks).Wait();
-
- var newHash = client.GetHashMap(null, FolderConstants.PithosContainer, fileName).Result;
+ var uploader = new Uploader();
+ uploader.UploadWithHashMap(accountInfo,cloudFile,fileInfo,fileName,treeHash);
+
+ var newHash = await client.GetHashMap(null, FolderConstants.PithosContainer, fileName);
- var treeHash = task.Result;
+
Assert.AreEqual(treeHash.TopHash, newHash.TopHash);
Assert.AreEqual(treeHash.Hashes, newHash.Hashes);
[Test]
public void TestDownload()
{
- var fileAgent = new FileAgent {FragmentsPath = @"e:\pithos\Fragments"};
-
var agent = new NetworkAgent();
- var account = "890329@vho.grnet.gr";
- var apiKey = "24989dce4e0fcb072f8cb60c8922be19";
+ var account = "";
+ var apiKey = "";
var client = new CloudFilesClient(account,apiKey)
{
AuthenticationUrl = @"https://pithos.dev.grnet.gr",
var cloudFile = new ObjectInfo {Account = account, Container = FolderConstants.PithosContainer};
var newHash = client.GetHashMap(null, FolderConstants.PithosContainer, fileName).Result;
- agent.DownloadWithBlocks(accountInfo, client, cloudFile, new Uri(fileName, UriKind.Relative), filePath, newHash)
+ var downloader = new Downloader();
+ downloader.DownloadWithBlocks(accountInfo, client, cloudFile, new Uri(fileName, UriKind.Relative), filePath, newHash)
.Wait();
Assert.IsTrue(File.Exists(filePath));
- var treeHash = Signature.CalculateTreeHashAsync(filePath, accountInfo.BlockSize, accountInfo.BlockHash).Result;
+ var treeHash = Signature.CalculateTreeHashAsync(filePath, accountInfo.BlockSize, accountInfo.BlockHash, 2).Result;
Assert.AreEqual(treeHash.TopHash, newHash.TopHash);