Fix for missing directories
[pithos-ms-client] / trunk / Pithos.Client.WPF.Test / NodeTest.cs
index db834fc..e37d87a 100644 (file)
@@ -3,7 +3,9 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using NUnit.Framework;
+using Pithos.Client.WPF.SelectiveSynch;
 using Pithos.Client.WPF.Utils;
+using Pithos.Interfaces;
 
 namespace Pithos.Client.WPF.Test
 {
@@ -120,6 +122,51 @@ namespace Pithos.Client.WPF.Test
                             };
 
             Assert.That(source.ToTree(s=>s.Item1,s=>s.Item2).First().Equals(target), Is.True);
+        } [Test]
+        
+        public void TestObjectInfoToTree()
+        {
+            var target = new DirectoryRecord{ DisplayName= "Root",
+                                Directories =
+                                    {
+                                        new DirectoryRecord{DisplayName = "Root/DisplayName1",
+                                            Directories =
+                                                {
+                                                    new DirectoryRecord{DisplayName="Root/DisplayName1/File2"},
+                                                    new DirectoryRecord{DisplayName="Root/DisplayName1/DisplayName11",
+                                                        Directories=
+                                                            {
+                                                                new DirectoryRecord{DisplayName="Root/DisplayName1/DisplayName11/DisplayName111",
+                                                                Directories=
+                                                                    {
+                                                                        new DirectoryRecord{DisplayName="Root/DisplayName1/DisplayName11/DisplayName111/File1"}        
+                                                                    }}
+                                                            }
+                                                    },
+                                                }
+                                        },                                        
+                                    }
+                            };
+            var account = "someaccount";
+            var container = "Root";
+            var source= new[]
+                            {
+                                new ObjectInfo{Account=account,Container=container,Name="Path1",Content_Type="application/directory"},
+                                new ObjectInfo{Account=account,Container=container,Name="Path1/Path11",Content_Type="application/folder"},
+                                new ObjectInfo{Account=account,Container=container,Name="Path1/Path11/Path111"},
+                                new ObjectInfo{Account=account,Container=container,Name="Path1/Path11/Path111/File1",Content_Type="application/octet-stream"},
+                                new ObjectInfo{Account=account,Container=container,Name="Path1/File2"},
+                                new ObjectInfo{Account=account,Container=container,Name="Path2/File2"},
+                                new ObjectInfo{Account=account,Container=container,Name="Path2/Path21/File2"},
+                                new ObjectInfo{Account=account,Container=container,Name="File02"},
+                                new ObjectInfo{Account=account,Container=container,Name="File03"}
+                            };
+
+            var tree = source.ToTree();
+            var allNodes = (from DirectoryRecord root in tree
+                            from DirectoryRecord record in root
+                            select record).ToList();    
+            Assert.That(allNodes.Count,Is.EqualTo(5));
         }
     }
 }