2 using System.Collections.Generic;
6 using Pithos.Client.WPF.SelectiveSynch;
7 using Pithos.Client.WPF.Utils;
8 using Pithos.Interfaces;
10 namespace Pithos.Client.WPF.Test
16 public void TestIteration()
18 var root = new Node<int>{Path = "Root",
21 new Node<int> {Path = "Root/Path1",
24 new Node<int>{Path="Root/Path1/Path11",
27 new Node<int>{Path="Root/Path1/Path11/Path111",
30 new Node<int>{Path="Root/Path1/Path11/Path111/File1"}
34 new Node<int>{Path="Root/Path1/File2"}
39 Assert.That(root.Count(), Is.EqualTo(6));
43 public void TestEquals()
45 var target = new Node<int>{Path = "Root",
48 new Node<int> {Path = "Root/Path1",
51 new Node<int>{Path="Root/Path1/Path11",
54 new Node<int>{Path="Root/Path1/Path11/Path111",
57 new Node<int>{Path="Root/Path1/Path11/Path111/File1"}
61 new Node<int>{Path="Root/Path1/File2"}
66 var source= new Node<int>{Path = "Root",
69 new Node<int>{Path = "Root/Path1",
72 new Node<int>{Path="Root/Path1/Path11",
75 new Node<int>{Path="Root/Path1/Path11/Path111",
78 new Node<int>{Path="Root/Path1/Path11/Path111/File1"}
82 new Node<int>{Path="Root/Path1/File2"}
87 Assert.That(source.Equals(target), Is.True);
91 public void TestToTree()
93 var target = new Node<int>{Path = "Root",
96 new Node<int>{Path = "Root/Path1",
99 new Node<int>{Path="Root/Path1/File2"},
100 new Node<int>{Path="Root/Path1/Path11",
103 new Node<int>{Path="Root/Path1/Path11/Path111",
106 new Node<int>{Path="Root/Path1/Path11/Path111/File1"}
116 Tuple.Create("Root",0),
117 Tuple.Create("Root/Path1",0),
118 Tuple.Create("Root/Path1/Path11",0),
119 Tuple.Create("Root/Path1/Path11/Path111",0),
120 Tuple.Create("Root/Path1/Path11/Path111/File1",0),
121 Tuple.Create("Root/Path1/File2",0)
124 Assert.That(source.ToTree(s=>s.Item1,s=>s.Item2).First().Equals(target), Is.True);
127 public void TestObjectInfoToTree()
129 var target = new DirectoryRecord{ DisplayName= "Root",
132 new DirectoryRecord{DisplayName = "Root/DisplayName1",
135 new DirectoryRecord{DisplayName="Root/DisplayName1/File2"},
136 new DirectoryRecord{DisplayName="Root/DisplayName1/DisplayName11",
139 new DirectoryRecord{DisplayName="Root/DisplayName1/DisplayName11/DisplayName111",
142 new DirectoryRecord{DisplayName="Root/DisplayName1/DisplayName11/DisplayName111/File1"}
150 var account = "someaccount";
151 var container = "Root";
154 new ObjectInfo{Account=account,Container=container,Name="Path1",Content_Type="application/directory"},
155 new ObjectInfo{Account=account,Container=container,Name="Path1/Path11",Content_Type="application/folder"},
156 new ObjectInfo{Account=account,Container=container,Name="Path1/Path11/Path111"},
157 new ObjectInfo{Account=account,Container=container,Name="Path1/Path11/Path111/File1",Content_Type="application/octet-stream"},
158 new ObjectInfo{Account=account,Container=container,Name="Path1/File2"},
159 new ObjectInfo{Account=account,Container=container,Name="Path2/File2"},
160 new ObjectInfo{Account=account,Container=container,Name="Path2/Path21/File2"},
161 new ObjectInfo{Account=account,Container=container,Name="File02"},
162 new ObjectInfo{Account=account,Container=container,Name="File03"}
165 var tree = source.ToTree();
166 var allNodes = (from DirectoryRecord root in tree
167 from DirectoryRecord record in root
168 select record).ToList();
169 Assert.That(allNodes.Count,Is.EqualTo(5));