Added unhandled exception handlers
[pithos-ms-client] / trunk / Pithos.Network.Test / ChecksumTest.cs
index 42030f3..222dc7d 100644 (file)
@@ -13,12 +13,19 @@ namespace Pithos.Network.Test
     [TestFixture]
     class ChecksumTest
     {
+
+        private string _apiKey = "9d3cb7b231e96f72ebe96af1c6cd5112";
+        private string _userName = "pkanavos";
+        private bool _usePithos = true;
+
         private ICloudClient client;
         [SetUp]
         public void Setup()
         {
-            client = new CloudFilesClient();
-            client.Authenticate("", "");
+            var account = "890329@vho.grnet.gr";
+            var apiKey = "24989dce4e0fcb072f8cb60c8922be19";
+            var client = new CloudFilesClient(account, apiKey);
+            client.Authenticate();
             
         }
 
@@ -28,35 +35,35 @@ namespace Pithos.Network.Test
             Assert.DoesNotThrow(() =>
             {
 
-                var filePath = @"e:\DeveloperGuide.pdf";
+                var filePath = "devguide.pdf";
                 var info=new FileInfo(filePath);
 
-                using (var file = File.OpenRead(filePath))
-                {
-                    var hash = CalculateHash(file);
-                    file.Seek(0, 0);
-                    client.PutObject("Shares", info.Name, file, info.Length);
+               
+                    var hash = CalculateHash(filePath);
+                    
+                    client.PutObject(null, "Shares", info.Name, filePath);
 
 
-                    var meta = client.GetObjectInfo("Shares", "DeveloperGuide.pdf");
+                    var meta = client.GetObjectInfo(null, "Shares", "DeveloperGuide.pdf");
                     Assert.IsNotEmpty(meta.Hash);
                     
 
                     Assert.AreEqual(hash,meta.Hash,String.Format("The hashes don't match, expected {0} but got {1}",hash,meta.Hash));
-                }
+                
 
             });
 
         
         }
 
-        private static string CalculateHash(FileStream file)
+        private static string CalculateHash(string fileName)
         {
             string hash;
             using (var hasher = MD5.Create())
+            using(var stream=File.OpenRead(fileName))
             {
                 var hashBuilder = new StringBuilder();
-                foreach (byte b in hasher.ComputeHash(file))
+                foreach (byte b in hasher.ComputeHash(stream))
                     hashBuilder.Append(b.ToString("x2").ToLower());
                 hash = hashBuilder.ToString();
             }