diff options
author | Sean Dague | 2008-09-12 21:00:40 +0000 |
---|---|---|
committer | Sean Dague | 2008-09-12 21:00:40 +0000 |
commit | ecc2a0f8669eb54892b00a6748612be4b318695d (patch) | |
tree | 31c6212ab29a9b3aba679686e72955422a046cdb | |
parent | reformat spacing on some property declarations. Take away the virtual (diff) | |
download | opensim-SC-ecc2a0f8669eb54892b00a6748612be4b318695d.zip opensim-SC-ecc2a0f8669eb54892b00a6748612be4b318695d.tar.gz opensim-SC-ecc2a0f8669eb54892b00a6748612be4b318695d.tar.bz2 opensim-SC-ecc2a0f8669eb54892b00a6748612be4b318695d.tar.xz |
add first round of folder tests
-rw-r--r-- | OpenSim/Data/Tests/BasicInventoryTest.cs | 142 |
1 files changed, 98 insertions, 44 deletions
diff --git a/OpenSim/Data/Tests/BasicInventoryTest.cs b/OpenSim/Data/Tests/BasicInventoryTest.cs index a6f81f9..7ba8b1f 100644 --- a/OpenSim/Data/Tests/BasicInventoryTest.cs +++ b/OpenSim/Data/Tests/BasicInventoryTest.cs | |||
@@ -40,41 +40,84 @@ namespace OpenSim.Data.Tests | |||
40 | { | 40 | { |
41 | public IInventoryDataPlugin db; | 41 | public IInventoryDataPlugin db; |
42 | public UUID zero = UUID.Zero; | 42 | public UUID zero = UUID.Zero; |
43 | public UUID uuid1; | 43 | |
44 | public UUID uuid2; | 44 | public UUID folder1; |
45 | public UUID uuid3; | 45 | public UUID folder2; |
46 | public UUID folder3; | ||
46 | public UUID owner1; | 47 | public UUID owner1; |
47 | public UUID owner2; | 48 | public UUID owner2; |
48 | public UUID owner3; | 49 | public UUID owner3; |
50 | |||
51 | public UUID item1; | ||
52 | public UUID item2; | ||
53 | public UUID item3; | ||
54 | public UUID asset1; | ||
55 | public UUID asset2; | ||
56 | public UUID asset3; | ||
57 | |||
49 | public string name1; | 58 | public string name1; |
50 | public string name2; | 59 | public string name2; |
51 | public string name3; | 60 | public string name3; |
61 | public string iname1; | ||
62 | public string iname2; | ||
63 | public string iname3; | ||
52 | 64 | ||
53 | public void SuperInit() | 65 | public void SuperInit() |
54 | { | 66 | { |
55 | uuid1 = UUID.Random(); | 67 | folder1 = UUID.Random(); |
56 | uuid2 = UUID.Random(); | 68 | folder2 = UUID.Random(); |
57 | uuid3 = UUID.Random(); | 69 | folder3 = UUID.Random(); |
58 | owner1 = UUID.Random(); | 70 | owner1 = UUID.Random(); |
59 | owner2 = UUID.Random(); | 71 | owner2 = UUID.Random(); |
60 | owner3 = UUID.Random(); | 72 | owner3 = UUID.Random(); |
73 | item1 = UUID.Random(); | ||
74 | item2 = UUID.Random(); | ||
75 | item3 = UUID.Random(); | ||
76 | asset1 = UUID.Random(); | ||
77 | asset2 = UUID.Random(); | ||
78 | asset3 = UUID.Random(); | ||
79 | |||
61 | name1 = "Root Folder for " + owner1.ToString(); | 80 | name1 = "Root Folder for " + owner1.ToString(); |
62 | name2 = "First Level folder"; | 81 | name2 = "First Level folder"; |
63 | name3 = "First Level folder 2"; | 82 | name3 = "First Level folder 2"; |
83 | iname1 = "Shirt"; | ||
84 | iname2 = "Text Board"; | ||
85 | iname3 = "No Pants Barrel"; | ||
86 | |||
64 | } | 87 | } |
65 | 88 | ||
66 | [Test] | 89 | [Test] |
67 | public void T001_LoadEmpty() | 90 | public void T001_LoadEmpty() |
68 | { | 91 | { |
69 | Assert.That(db.getInventoryItem(uuid1), Is.Null); | 92 | Assert.That(db.getInventoryFolder(zero), Is.Null); |
93 | Assert.That(db.getInventoryFolder(folder1), Is.Null); | ||
94 | Assert.That(db.getInventoryFolder(folder2), Is.Null); | ||
95 | Assert.That(db.getInventoryFolder(folder3), Is.Null); | ||
96 | |||
97 | Assert.That(db.getInventoryItem(zero), Is.Null); | ||
98 | Assert.That(db.getInventoryItem(item1), Is.Null); | ||
99 | Assert.That(db.getInventoryItem(item2), Is.Null); | ||
100 | Assert.That(db.getInventoryItem(item3), Is.Null); | ||
101 | |||
102 | Assert.That(db.getUserRootFolder(zero), Is.Null); | ||
70 | Assert.That(db.getUserRootFolder(owner1), Is.Null); | 103 | Assert.That(db.getUserRootFolder(owner1), Is.Null); |
71 | } | 104 | } |
72 | 105 | ||
106 | [Test] | ||
107 | public void T999_StillNull() | ||
108 | { | ||
109 | // After all tests are run, these should still return no results | ||
110 | Assert.That(db.getInventoryFolder(zero), Is.Null); | ||
111 | Assert.That(db.getInventoryItem(zero), Is.Null); | ||
112 | Assert.That(db.getUserRootFolder(zero), Is.Null); | ||
113 | Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0)); | ||
114 | } | ||
115 | |||
73 | // 01x - folder tests | 116 | // 01x - folder tests |
74 | [Test] | 117 | [Test] |
75 | public void T010_FolderNonParent() | 118 | public void T010_FolderNonParent() |
76 | { | 119 | { |
77 | InventoryFolderBase f1 = NewFolder(uuid2, uuid1, owner1, name2); | 120 | InventoryFolderBase f1 = NewFolder(folder2, folder1, owner1, name2); |
78 | // the folder will go in | 121 | // the folder will go in |
79 | db.addInventoryFolder(f1); | 122 | db.addInventoryFolder(f1); |
80 | InventoryFolderBase f1a = db.getUserRootFolder(owner1); | 123 | InventoryFolderBase f1a = db.getUserRootFolder(owner1); |
@@ -84,7 +127,7 @@ namespace OpenSim.Data.Tests | |||
84 | [Test] | 127 | [Test] |
85 | public void T011_FolderCreate() | 128 | public void T011_FolderCreate() |
86 | { | 129 | { |
87 | InventoryFolderBase f1 = NewFolder(uuid1, zero, owner1, name1); | 130 | InventoryFolderBase f1 = NewFolder(folder1, zero, owner1, name1); |
88 | // TODO: this is probably wrong behavior, but is what we have | 131 | // TODO: this is probably wrong behavior, but is what we have |
89 | // db.updateInventoryFolder(f1); | 132 | // db.updateInventoryFolder(f1); |
90 | // InventoryFolderBase f1a = db.getUserRootFolder(owner1); | 133 | // InventoryFolderBase f1a = db.getUserRootFolder(owner1); |
@@ -95,29 +138,25 @@ namespace OpenSim.Data.Tests | |||
95 | // succeed with true | 138 | // succeed with true |
96 | db.addInventoryFolder(f1); | 139 | db.addInventoryFolder(f1); |
97 | InventoryFolderBase f1a = db.getUserRootFolder(owner1); | 140 | InventoryFolderBase f1a = db.getUserRootFolder(owner1); |
98 | Assert.That(uuid1, Is.EqualTo(f1a.ID)); | 141 | Assert.That(folder1, Is.EqualTo(f1a.ID)); |
99 | Assert.That(name1, Text.Matches(f1a.Name)); | 142 | Assert.That(name1, Text.Matches(f1a.Name)); |
100 | } | 143 | } |
101 | 144 | ||
102 | // we now have the following tree | 145 | // we now have the following tree |
103 | // uuid1 | 146 | // folder1 |
104 | // +--- uuid2 | 147 | // +--- folder2 |
105 | // +--- uuid3 | 148 | // +--- folder3 |
106 | 149 | ||
107 | [Test] | 150 | [Test] |
108 | public void T012_FolderList() | 151 | public void T012_FolderList() |
109 | { | 152 | { |
110 | InventoryFolderBase f2 = NewFolder(uuid3, uuid1, owner1, name3); | 153 | InventoryFolderBase f2 = NewFolder(folder3, folder1, owner1, name3); |
111 | db.addInventoryFolder(f2); | 154 | db.addInventoryFolder(f2); |
112 | 155 | ||
113 | Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1)); | 156 | Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1)); |
114 | 157 | Assert.That(db.getInventoryFolders(folder1).Count, Is.EqualTo(2)); | |
115 | Assert.That(db.getInventoryFolders(uuid1).Count, Is.EqualTo(2)); | 158 | Assert.That(db.getInventoryFolders(folder2).Count, Is.EqualTo(0)); |
116 | 159 | Assert.That(db.getInventoryFolders(folder3).Count, Is.EqualTo(0)); | |
117 | Assert.That(db.getInventoryFolders(uuid2).Count, Is.EqualTo(0)); | ||
118 | |||
119 | Assert.That(db.getInventoryFolders(uuid3).Count, Is.EqualTo(0)); | ||
120 | |||
121 | Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0)); | 160 | Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0)); |
122 | 161 | ||
123 | } | 162 | } |
@@ -126,13 +165,9 @@ namespace OpenSim.Data.Tests | |||
126 | public void T013_FolderHierarchy() | 165 | public void T013_FolderHierarchy() |
127 | { | 166 | { |
128 | Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0)); | 167 | Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0)); |
129 | 168 | Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2)); | |
130 | Assert.That(db.getFolderHierarchy(uuid1).Count, Is.EqualTo(2)); | 169 | Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0)); |
131 | 170 | Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(0)); | |
132 | Assert.That(db.getFolderHierarchy(uuid2).Count, Is.EqualTo(0)); | ||
133 | |||
134 | Assert.That(db.getFolderHierarchy(uuid3).Count, Is.EqualTo(0)); | ||
135 | |||
136 | Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0)); | 171 | Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0)); |
137 | } | 172 | } |
138 | 173 | ||
@@ -140,18 +175,14 @@ namespace OpenSim.Data.Tests | |||
140 | [Test] | 175 | [Test] |
141 | public void T014_MoveFolder() | 176 | public void T014_MoveFolder() |
142 | { | 177 | { |
143 | InventoryFolderBase f2 = db.getInventoryFolder(uuid2); | 178 | InventoryFolderBase f2 = db.getInventoryFolder(folder2); |
144 | f2.ParentID = uuid3; | 179 | f2.ParentID = folder3; |
145 | db.moveInventoryFolder(f2); | 180 | db.moveInventoryFolder(f2); |
146 | 181 | ||
147 | Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1)); | 182 | Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1)); |
148 | 183 | Assert.That(db.getInventoryFolders(folder1).Count, Is.EqualTo(1)); | |
149 | Assert.That(db.getInventoryFolders(uuid1).Count, Is.EqualTo(1)); | 184 | Assert.That(db.getInventoryFolders(folder2).Count, Is.EqualTo(0)); |
150 | 185 | Assert.That(db.getInventoryFolders(folder3).Count, Is.EqualTo(1)); | |
151 | Assert.That(db.getInventoryFolders(uuid2).Count, Is.EqualTo(0)); | ||
152 | |||
153 | Assert.That(db.getInventoryFolders(uuid3).Count, Is.EqualTo(1)); | ||
154 | |||
155 | Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0)); | 186 | Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0)); |
156 | } | 187 | } |
157 | 188 | ||
@@ -159,17 +190,40 @@ namespace OpenSim.Data.Tests | |||
159 | public void T015_FolderHierarchy() | 190 | public void T015_FolderHierarchy() |
160 | { | 191 | { |
161 | Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0)); | 192 | Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0)); |
162 | 193 | Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2)); | |
163 | Assert.That(db.getFolderHierarchy(uuid1).Count, Is.EqualTo(2)); | 194 | Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0)); |
164 | 195 | Assert.That(db.getFolderHierarchy(folder3).Count, Is.EqualTo(1)); | |
165 | Assert.That(db.getFolderHierarchy(uuid2).Count, Is.EqualTo(0)); | ||
166 | |||
167 | Assert.That(db.getFolderHierarchy(uuid3).Count, Is.EqualTo(1)); | ||
168 | |||
169 | Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0)); | 196 | Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0)); |
170 | } | 197 | } |
171 | 198 | ||
199 | // Item tests | ||
200 | public void T100_NoItems() | ||
201 | { | ||
202 | Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0)); | ||
203 | Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0)); | ||
204 | Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0)); | ||
205 | Assert.That(db.getInventoryInFolder(folder3).Count, Is.EqualTo(0)); | ||
206 | } | ||
207 | |||
208 | public void T101_CreatItems() | ||
209 | { | ||
210 | db.addInventoryItem(NewItem(item1, folder3, owner1, iname1, asset1)); | ||
211 | db.addInventoryItem(NewItem(item2, folder3, owner1, iname2, asset2)); | ||
212 | db.addInventoryItem(NewItem(item3, folder3, owner1, iname3, asset3)); | ||
213 | Assert.That(db.getInventoryInFolder(folder3).Count, Is.EqualTo(3)); | ||
214 | } | ||
215 | |||
172 | 216 | ||
217 | private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset) | ||
218 | { | ||
219 | InventoryItemBase i = new InventoryItemBase(); | ||
220 | i.ID = id; | ||
221 | i.Folder = parent; | ||
222 | i.Owner = owner; | ||
223 | i.Name = name; | ||
224 | i.AssetID = asset; | ||
225 | return i; | ||
226 | } | ||
173 | 227 | ||
174 | private InventoryFolderBase NewFolder(UUID id, UUID parent, UUID owner, string name) | 228 | private InventoryFolderBase NewFolder(UUID id, UUID parent, UUID owner, string name) |
175 | { | 229 | { |