Fixed handling for Content_Type "application/folder" in SelectiveSync and other locations
[pithos-ms-client] / trunk / Pithos.Network.Test / CloudFilesClientTest.cs
1 using System;
2 using System.Collections.Concurrent;
3 using System.Collections.Generic;
4 using System.IO;
5 using System.Linq;
6 using System.Text;
7 using System.Threading.Tasks;
8 using NUnit.Framework;
9
10 namespace Pithos.Network.Test
11 {
12     [TestFixture]
13     class CloudFilesClientTest
14     {
15         [Test]
16         public void TestPutHashMap()
17         {
18             var account = "890329@vho.grnet.gr";
19             var apiKey = "24989dce4e0fcb072f8cb60c8922be19";
20             var client = new CloudFilesClient(account, apiKey)
21             {
22                                  AuthenticationUrl = @"https://pithos.dev.grnet.gr", 
23                                  UsePithos = true
24                              };
25             client.Authenticate();
26             var fileName = @"vlc-1.1.11-win32.exe";
27             var treeHash=Signature.CalculateTreeHashAsync(Path.Combine(@"e:\pithos\" ,fileName), 4*1024*1024 , "sha256", 2).Result;
28             var result = client.PutHashMap(account, "pithos", fileName, treeHash).Result;
29
30             Assert.AreEqual(0,result.Count);
31         }
32         
33         [Test]
34         public void TestAuthentication()
35         {
36             var account = "ikons@cslab.ece.ntua.gr";
37             var apiKey = "fKzKaRd7Uhov+xca4B4rOQ==";
38             var client = new CloudFilesClient(account, apiKey)
39             {
40                                  AuthenticationUrl = @"https://plus.pithos.grnet.gr", 
41                                  UsePithos = true
42                              };
43             var accountInfo=client.Authenticate();
44             var containers=client.ListContainers(accountInfo.UserName);
45             Assert.IsNotNull(containers);
46             var result=client.GetAccountPolicies(accountInfo);
47
48             Assert.IsNotNull(accountInfo);
49             Assert.IsNotNull(result);
50         }
51
52
53         [Test]
54         public void TestFolders()
55         {
56             var account = "pkanavos@gmail.com";
57             var apiKey = "kAhnqSZwzzCMMjtPHkuFhw==";
58
59             var client = new CloudFilesClient(account, apiKey)
60                              {
61                                  AuthenticationUrl = @"https://pithos.dev.grnet.gr",
62                                  UsePithos = true
63                              };
64             var accountInfo = client.Authenticate();
65             var containers = client.ListContainers(accountInfo.UserName);
66             Assert.IsNotNull(containers);
67             var result = client.GetAccountPolicies(accountInfo);
68
69             Assert.IsNotNull(accountInfo);
70             Assert.IsNotNull(result);
71
72
73             var pithos=containers.First(c => c.Name == "pithos");
74             var directories=client.ListObjects(account,"pithos","").Where(info=>info.IsDirectory);
75             Assert.That(directories,!Is.Empty);
76             Assert.IsTrue(directories.All(info=>info.IsDirectory));
77         }
78
79
80
81        
82     }
83 }