diff options
author | Tleiades Hax | 2007-10-10 17:00:29 +0000 |
---|---|---|
committer | Tleiades Hax | 2007-10-10 17:00:29 +0000 |
commit | 87d99ee2a24f7fc8a4ad3c11327395997cf0d42f (patch) | |
tree | a266ed727678395d92c7cd069f4cd5ae1a762fd1 | |
parent | some refactoring (diff) | |
download | opensim-SC-87d99ee2a24f7fc8a4ad3c11327395997cf0d42f.zip opensim-SC-87d99ee2a24f7fc8a4ad3c11327395997cf0d42f.tar.gz opensim-SC-87d99ee2a24f7fc8a4ad3c11327395997cf0d42f.tar.bz2 opensim-SC-87d99ee2a24f7fc8a4ad3c11327395997cf0d42f.tar.xz |
Added unit tests, based on nunit for the IInventoryData
-rw-r--r-- | OpenSim/Tests/Inventory/Properties/AssemblyInfo.cs | 35 | ||||
-rw-r--r-- | OpenSim/Tests/Inventory/TestInventory.cs | 980 |
2 files changed, 1015 insertions, 0 deletions
diff --git a/OpenSim/Tests/Inventory/Properties/AssemblyInfo.cs b/OpenSim/Tests/Inventory/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dd537a5 --- /dev/null +++ b/OpenSim/Tests/Inventory/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,35 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("Inventory")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("Lauridsen")] | ||
12 | [assembly: AssemblyProduct("Inventory")] | ||
13 | [assembly: AssemblyCopyright("Copyright © Lauridsen 2007")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("2330add7-08a2-4f33-9ab8-74894fe7e3dd")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | // You can specify all the values or you can default the Revision and Build Numbers | ||
33 | // by using the '*' as shown below: | ||
34 | [assembly: AssemblyVersion("1.0.0.0")] | ||
35 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Tests/Inventory/TestInventory.cs b/OpenSim/Tests/Inventory/TestInventory.cs new file mode 100644 index 0000000..067f114 --- /dev/null +++ b/OpenSim/Tests/Inventory/TestInventory.cs | |||
@@ -0,0 +1,980 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using NUnit.Framework; | ||
5 | |||
6 | using libsecondlife; | ||
7 | using OpenSim.Framework.Types; | ||
8 | using OpenSim.Framework.Data; | ||
9 | using OpenSim.Framework.Data.SQLite; | ||
10 | using OpenSim.Framework.Data.MySQL; | ||
11 | using OpenSim.Framework.Console; | ||
12 | |||
13 | namespace OpenSim.Test.Inventory | ||
14 | { | ||
15 | [TestFixture] | ||
16 | public class TestInventory | ||
17 | { | ||
18 | IInventoryData _dbPlugin; | ||
19 | LLUUID _agent_1_id; | ||
20 | public static LLUUID LibraryFolderRootUuid = new LLUUID("5926de2a-c2d7-4c11-ac4e-74512ffeb6d1"); | ||
21 | |||
22 | Random _rnd = new Random((int)DateTime.Now.Ticks); | ||
23 | |||
24 | [TestFixtureSetUp] | ||
25 | public void SetupInventoryTest() | ||
26 | { | ||
27 | |||
28 | _agent_1_id = LLUUID.Random(); | ||
29 | |||
30 | MainLog.Instance = new LogBase("UnitTest.log", "TEST", null, true); | ||
31 | // _dbPlugin = new SQLiteInventoryStore(); | ||
32 | _dbPlugin = new MySQLInventoryData(); | ||
33 | _dbPlugin.Initialise(); | ||
34 | } | ||
35 | |||
36 | [TestFixtureTearDown] | ||
37 | public void TeardownInventoryTest() | ||
38 | { | ||
39 | _dbPlugin.Close(); | ||
40 | } | ||
41 | |||
42 | private bool AreFoldersIdentical(InventoryFolderBase a, InventoryFolderBase b) | ||
43 | { | ||
44 | if (a.agentID != b.agentID) return false; | ||
45 | if (a.folderID != b.folderID) return false; | ||
46 | if (a.name != b.name) return false; | ||
47 | if (a.parentID != b.parentID) return false; | ||
48 | if (a.type != b.type) return false; | ||
49 | if (a.version != b.version) return false; | ||
50 | return true; | ||
51 | } | ||
52 | |||
53 | private bool AreItemsIdentical(InventoryItemBase a, InventoryItemBase b) | ||
54 | { | ||
55 | if (a.assetID != b.assetID) return false; | ||
56 | if (a.assetType != b.assetType) return false; | ||
57 | if (a.avatarID != b.avatarID) return false; | ||
58 | if (a.creatorsID != b.creatorsID) return false; | ||
59 | if (a.inventoryBasePermissions != b.inventoryBasePermissions) return false; | ||
60 | if (a.inventoryCurrentPermissions != b.inventoryCurrentPermissions) return false; | ||
61 | if (a.inventoryEveryOnePermissions != b.inventoryEveryOnePermissions) return false; | ||
62 | if (a.inventoryNextPermissions != b.inventoryNextPermissions) return false; | ||
63 | if (a.inventoryID != b.inventoryID) return false; | ||
64 | if (a.inventoryDescription != b.inventoryDescription) return false; | ||
65 | if (a.inventoryName != b.inventoryName) return false; | ||
66 | if (a.invType != b.invType) return false; | ||
67 | if (a.parentFolderID != b.parentFolderID) return false; | ||
68 | return true; | ||
69 | } | ||
70 | |||
71 | /// <summary> | ||
72 | /// Test that we can insert a root folder | ||
73 | /// </summary> | ||
74 | [Test] | ||
75 | public void T01_SetupRootFolder() | ||
76 | { | ||
77 | InventoryFolderBase root = new InventoryFolderBase(); | ||
78 | root.agentID = _agent_1_id; | ||
79 | root.folderID = _agent_1_id; | ||
80 | root.name = "Root folder"; | ||
81 | root.parentID = LLUUID.Zero; | ||
82 | root.type = 2; | ||
83 | root.version = 2; | ||
84 | _dbPlugin.addInventoryFolder(root); | ||
85 | |||
86 | InventoryFolderBase f = _dbPlugin.getInventoryFolder(root.folderID); | ||
87 | Assert.IsNotNull(f, "Failed to get existing folder"); | ||
88 | Assert.IsTrue(AreFoldersIdentical(root, f), "Difference between stored and retrieved folder data"); | ||
89 | |||
90 | // Test that we only get the root folder, based on it's id, i.e. any other gui will not find the folder | ||
91 | f = _dbPlugin.getInventoryFolder(LLUUID.Zero); | ||
92 | Assert.IsNull(f, "get folder returned a folder, but shouldn't find one"); | ||
93 | |||
94 | f = _dbPlugin.getInventoryFolder(LLUUID.Random()); | ||
95 | Assert.IsNull(f, "get folder returned a folder, but shouldn't find one"); | ||
96 | |||
97 | // test that we can delete the folder | ||
98 | |||
99 | _dbPlugin.deleteInventoryFolder(_agent_1_id); | ||
100 | f = _dbPlugin.getInventoryFolder(root.folderID); | ||
101 | Assert.IsNull(f, "get folder returned a folder, but it should have been deleted"); | ||
102 | } | ||
103 | |||
104 | /// <summary> | ||
105 | /// Make sure that all folders reported as root folders are root folders | ||
106 | /// </summary> | ||
107 | [Test] | ||
108 | public void T02_TestRootFolder() | ||
109 | { | ||
110 | InventoryFolderBase root = new InventoryFolderBase(); | ||
111 | root.agentID = _agent_1_id; | ||
112 | root.folderID = _agent_1_id; | ||
113 | root.name = "Root folder"; | ||
114 | root.parentID = LLUUID.Zero; | ||
115 | root.type = 2; | ||
116 | root.version = 2; | ||
117 | _dbPlugin.addInventoryFolder(root); | ||
118 | |||
119 | List<InventoryFolderBase> folders = _dbPlugin.getUserRootFolders(_agent_1_id); | ||
120 | Assert.IsNotNull(folders, "Failed to get rootfolders for user"); | ||
121 | |||
122 | bool foundRoot = false; | ||
123 | foreach(InventoryFolderBase f in folders) { | ||
124 | |||
125 | // a root folder has a zero valued LLUUID | ||
126 | Assert.AreEqual(f.parentID, LLUUID.Zero, "non root folder returned"); | ||
127 | |||
128 | |||
129 | if(f.agentID == root.agentID) | ||
130 | { | ||
131 | // we cannot have two different user specific root folders | ||
132 | Assert.IsFalse(foundRoot, "Two different user specific root folders returned"); | ||
133 | |||
134 | Assert.IsTrue(AreFoldersIdentical(root, f), "Difference between stored and retrieved folder data"); | ||
135 | foundRoot = false; | ||
136 | } | ||
137 | } | ||
138 | _dbPlugin.deleteInventoryFolder(_agent_1_id); | ||
139 | } | ||
140 | |||
141 | /// <summary> | ||
142 | /// Test of folder hierarchy | ||
143 | /// </summary> | ||
144 | [Test] | ||
145 | public void T03_TestRootFolder() | ||
146 | { | ||
147 | InventoryFolderBase root = new InventoryFolderBase(); | ||
148 | root.agentID = _agent_1_id; | ||
149 | root.folderID = _agent_1_id; | ||
150 | root.name = "Root folder"; | ||
151 | root.parentID = LLUUID.Zero; | ||
152 | root.type = 2; | ||
153 | root.version = 2; | ||
154 | _dbPlugin.addInventoryFolder(root); | ||
155 | |||
156 | List<InventoryFolderBase> folders = _dbPlugin.getInventoryFolders(_agent_1_id); | ||
157 | Assert.IsNotNull(folders, "null was returned, but an empty list of subfolders were expected"); | ||
158 | Assert.IsEmpty(folders, "non empty collection was returned, even though the list of sub-folders should be empty"); | ||
159 | |||
160 | InventoryFolderBase child1 = new InventoryFolderBase(); | ||
161 | child1.agentID = _agent_1_id; | ||
162 | child1.folderID = LLUUID.Random(); | ||
163 | child1.name = "Child 1"; | ||
164 | child1.parentID = root.folderID; | ||
165 | child1.type = 3; | ||
166 | child1.version = 3; | ||
167 | _dbPlugin.addInventoryFolder(child1); | ||
168 | |||
169 | InventoryFolderBase child2 = new InventoryFolderBase(); | ||
170 | child2.agentID = _agent_1_id; | ||
171 | child2.folderID = LLUUID.Random(); | ||
172 | child2.name = "Child 2"; | ||
173 | child2.parentID = root.folderID; | ||
174 | child2.type = 4; | ||
175 | child2.version = 4; | ||
176 | _dbPlugin.addInventoryFolder(child2); | ||
177 | |||
178 | folders = _dbPlugin.getInventoryFolders(_agent_1_id); | ||
179 | Assert.IsNotNull(folders, "null was returned, but an empty list of subfolders were expected"); | ||
180 | Assert.AreEqual(folders.Count, 2, "two children were reported as inserted into the root folder"); | ||
181 | |||
182 | bool foundChild1 = false; | ||
183 | bool foundChild2 = false; | ||
184 | |||
185 | foreach (InventoryFolderBase f in folders) | ||
186 | { | ||
187 | if (f.folderID == child1.folderID) | ||
188 | { | ||
189 | Assert.IsTrue(AreFoldersIdentical(child1, f), "Difference between stored and retrieved folder data"); | ||
190 | foundChild1 = true; | ||
191 | } | ||
192 | else if (f.folderID == child2.folderID) | ||
193 | { | ||
194 | Assert.IsTrue(AreFoldersIdentical(child2, f), "Difference between stored and retrieved folder data"); | ||
195 | foundChild2 = true; | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | Assert.Fail("found unknown child folder"); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | if (foundChild1 == false || foundChild2 == false) | ||
204 | { | ||
205 | Assert.Fail("one of the two child folders was not returned"); | ||
206 | } | ||
207 | |||
208 | _dbPlugin.deleteInventoryFolder(child2.folderID); | ||
209 | _dbPlugin.deleteInventoryFolder(child1.folderID); | ||
210 | _dbPlugin.deleteInventoryFolder(_agent_1_id); | ||
211 | } | ||
212 | |||
213 | /// <summary> | ||
214 | /// Test of folder hierarchy, and deletion | ||
215 | /// </summary> | ||
216 | [Test] | ||
217 | public void T04_TestRootFolder() | ||
218 | { | ||
219 | InventoryFolderBase root = new InventoryFolderBase(); | ||
220 | root.agentID = _agent_1_id; | ||
221 | root.folderID = _agent_1_id; | ||
222 | root.name = "Root folder"; | ||
223 | root.parentID = LLUUID.Zero; | ||
224 | root.type = 2; | ||
225 | root.version = 2; | ||
226 | _dbPlugin.addInventoryFolder(root); | ||
227 | |||
228 | InventoryFolderBase child1 = new InventoryFolderBase(); | ||
229 | child1.agentID = _agent_1_id; | ||
230 | child1.folderID = LLUUID.Random(); | ||
231 | child1.name = "Child 1"; | ||
232 | child1.parentID = root.folderID; | ||
233 | child1.type = 3; | ||
234 | child1.version = 3; | ||
235 | _dbPlugin.addInventoryFolder(child1); | ||
236 | |||
237 | InventoryFolderBase child2 = new InventoryFolderBase(); | ||
238 | child2.agentID = _agent_1_id; | ||
239 | child2.folderID = LLUUID.Random(); | ||
240 | child2.name = "Child 2"; | ||
241 | child2.parentID = root.folderID; | ||
242 | child2.type = 4; | ||
243 | child2.version = 4; | ||
244 | _dbPlugin.addInventoryFolder(child2); | ||
245 | |||
246 | _dbPlugin.deleteInventoryFolder(_agent_1_id); | ||
247 | |||
248 | List<InventoryFolderBase> folders = _dbPlugin.getInventoryFolders(_agent_1_id); | ||
249 | Assert.IsNotNull(folders, "null was returned, but an empty list of subfolders were expected"); | ||
250 | Assert.IsEmpty(folders, "non empty collection was returned, even though the list of sub-folders should be empty"); | ||
251 | |||
252 | InventoryFolderBase f = _dbPlugin.getInventoryFolder(_agent_1_id); | ||
253 | Assert.IsNull(f, "Folder was returned, even though is has been deleted"); | ||
254 | |||
255 | f = _dbPlugin.getInventoryFolder(child1.folderID); | ||
256 | Assert.IsNull(f, "Folder was returned, even though is has been deleted"); | ||
257 | |||
258 | f = _dbPlugin.getInventoryFolder(child2.folderID); | ||
259 | Assert.IsNull(f, "Folder was returned, even though is has been deleted"); | ||
260 | } | ||
261 | |||
262 | /// <summary> | ||
263 | /// Folder update | ||
264 | /// </summary> | ||
265 | [Test] | ||
266 | public void T05_UpdateFolder() | ||
267 | { | ||
268 | InventoryFolderBase root = new InventoryFolderBase(); | ||
269 | root.agentID = _agent_1_id; | ||
270 | root.folderID = _agent_1_id; | ||
271 | root.name = "Root folder"; | ||
272 | root.parentID = LLUUID.Zero; | ||
273 | root.type = 2; | ||
274 | root.version = 2; | ||
275 | _dbPlugin.addInventoryFolder(root); | ||
276 | |||
277 | InventoryFolderBase f = _dbPlugin.getInventoryFolder(_agent_1_id); | ||
278 | Assert.IsTrue(AreFoldersIdentical(root, f), "Difference between stored and retrieved folder data"); | ||
279 | |||
280 | root.agentID = LLUUID.Random(); | ||
281 | _dbPlugin.updateInventoryFolder(root); | ||
282 | f = _dbPlugin.getInventoryFolder(root.folderID); | ||
283 | Assert.IsTrue(AreFoldersIdentical(root, f), "Difference between stored and retrieved folder data"); | ||
284 | |||
285 | root.folderID = LLUUID.Random(); | ||
286 | _dbPlugin.updateInventoryFolder(root); | ||
287 | f = _dbPlugin.getInventoryFolder(root.folderID); | ||
288 | Assert.IsTrue(AreFoldersIdentical(root, f), "Difference between stored and retrieved folder data"); | ||
289 | |||
290 | root.name = "Root folder 2"; | ||
291 | _dbPlugin.updateInventoryFolder(root); | ||
292 | f = _dbPlugin.getInventoryFolder(root.folderID); | ||
293 | Assert.IsTrue(AreFoldersIdentical(root, f), "Difference between stored and retrieved folder data"); | ||
294 | |||
295 | root.parentID = LLUUID.Random(); | ||
296 | _dbPlugin.updateInventoryFolder(root); | ||
297 | f = _dbPlugin.getInventoryFolder(root.folderID); | ||
298 | Assert.IsTrue(AreFoldersIdentical(root, f), "Difference between stored and retrieved folder data"); | ||
299 | |||
300 | root.type = (short)(root.type + 1); | ||
301 | _dbPlugin.updateInventoryFolder(root); | ||
302 | f = _dbPlugin.getInventoryFolder(root.folderID); | ||
303 | Assert.IsTrue(AreFoldersIdentical(root, f), "Difference between stored and retrieved folder data"); | ||
304 | |||
305 | root.version = (ushort)(root.version + 1); | ||
306 | _dbPlugin.updateInventoryFolder(root); | ||
307 | f = _dbPlugin.getInventoryFolder(root.folderID); | ||
308 | Assert.IsTrue(AreFoldersIdentical(root, f), "Difference between stored and retrieved folder data"); | ||
309 | |||
310 | _dbPlugin.deleteInventoryFolder(_agent_1_id); | ||
311 | _dbPlugin.deleteInventoryFolder(root.folderID); | ||
312 | } | ||
313 | |||
314 | /// <summary> | ||
315 | /// Test that we can insert a root folder | ||
316 | /// </summary> | ||
317 | [Test] | ||
318 | public void T06_SetupInventoryWithItems() | ||
319 | { | ||
320 | |||
321 | // Setup inventory | ||
322 | InventoryFolderBase root = new InventoryFolderBase(); | ||
323 | root.agentID = _agent_1_id; | ||
324 | root.folderID = _agent_1_id; | ||
325 | root.name = "Root folder"; | ||
326 | root.parentID = LLUUID.Zero; | ||
327 | root.type = 2; | ||
328 | root.version = 2; | ||
329 | _dbPlugin.addInventoryFolder(root); | ||
330 | |||
331 | InventoryFolderBase child1 = new InventoryFolderBase(); | ||
332 | child1.agentID = _agent_1_id; | ||
333 | child1.folderID = LLUUID.Random(); | ||
334 | child1.name = "Child 1"; | ||
335 | child1.parentID = root.folderID; | ||
336 | child1.type = 3; | ||
337 | child1.version = 3; | ||
338 | _dbPlugin.addInventoryFolder(child1); | ||
339 | |||
340 | InventoryFolderBase child1Child = new InventoryFolderBase(); | ||
341 | child1Child.agentID = _agent_1_id; | ||
342 | child1Child.folderID = LLUUID.Random(); | ||
343 | child1Child.name = "Child 1 child"; | ||
344 | child1Child.parentID = child1.folderID; | ||
345 | child1Child.type = 4; | ||
346 | child1Child.version = 4; | ||
347 | _dbPlugin.addInventoryFolder(child1Child); | ||
348 | |||
349 | InventoryFolderBase child2 = new InventoryFolderBase(); | ||
350 | child2.agentID = _agent_1_id; | ||
351 | child2.folderID = LLUUID.Random(); | ||
352 | child2.name = "Child 2"; | ||
353 | child2.parentID = root.folderID; | ||
354 | child2.type = 5; | ||
355 | child2.version = 5; | ||
356 | _dbPlugin.addInventoryFolder(child2); | ||
357 | |||
358 | InventoryFolderBase child2Child = new InventoryFolderBase(); | ||
359 | child2Child.agentID = _agent_1_id; | ||
360 | child2Child.folderID = LLUUID.Random(); | ||
361 | child2Child.name = "Child 2 child"; | ||
362 | child2Child.parentID = child2.folderID; | ||
363 | child2Child.type = 6; | ||
364 | child2Child.version = 6; | ||
365 | _dbPlugin.addInventoryFolder(child2Child); | ||
366 | |||
367 | InventoryItemBase rootItem = new InventoryItemBase(); | ||
368 | rootItem.assetID = LLUUID.Random(); | ||
369 | rootItem.assetType = _rnd.Next(1, 1000); | ||
370 | rootItem.avatarID = _agent_1_id; | ||
371 | rootItem.creatorsID = LLUUID.Random(); | ||
372 | rootItem.inventoryBasePermissions = (uint)_rnd.Next(1,1000000); | ||
373 | rootItem.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
374 | rootItem.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
375 | rootItem.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
376 | rootItem.inventoryID = LLUUID.Random(); | ||
377 | rootItem.inventoryDescription = "Root item, Description"; | ||
378 | rootItem.inventoryName = "Root item"; | ||
379 | rootItem.invType = _rnd.Next(1, 1000); | ||
380 | rootItem.parentFolderID = root.folderID; | ||
381 | _dbPlugin.addInventoryItem(rootItem); | ||
382 | |||
383 | InventoryItemBase child1Item = new InventoryItemBase(); | ||
384 | child1Item.assetID = LLUUID.Random(); | ||
385 | child1Item.assetType = _rnd.Next(1, 1000); | ||
386 | child1Item.avatarID = _agent_1_id; | ||
387 | child1Item.creatorsID = LLUUID.Random(); | ||
388 | child1Item.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
389 | child1Item.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
390 | child1Item.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
391 | child1Item.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
392 | child1Item.inventoryID = LLUUID.Random(); | ||
393 | child1Item.inventoryDescription = "child1 item, Description"; | ||
394 | child1Item.inventoryName = "child1 item"; | ||
395 | child1Item.invType = _rnd.Next(1, 1000); | ||
396 | child1Item.parentFolderID = child1.folderID; | ||
397 | _dbPlugin.addInventoryItem(child1Item); | ||
398 | |||
399 | InventoryItemBase child1ChildItem = new InventoryItemBase(); | ||
400 | child1ChildItem.assetID = LLUUID.Random(); | ||
401 | child1ChildItem.assetType = _rnd.Next(1, 1000); | ||
402 | child1ChildItem.avatarID = _agent_1_id; | ||
403 | child1ChildItem.creatorsID = LLUUID.Random(); | ||
404 | child1ChildItem.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
405 | child1ChildItem.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
406 | child1ChildItem.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
407 | child1ChildItem.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
408 | child1ChildItem.inventoryID = LLUUID.Random(); | ||
409 | child1ChildItem.inventoryDescription = "child1Child item, Description"; | ||
410 | child1ChildItem.inventoryName = "child1Child item"; | ||
411 | child1ChildItem.invType = _rnd.Next(1, 1000); | ||
412 | child1ChildItem.parentFolderID = child1Child.folderID; | ||
413 | _dbPlugin.addInventoryItem(child1ChildItem); | ||
414 | |||
415 | InventoryItemBase child2Item = new InventoryItemBase(); | ||
416 | child2Item.assetID = LLUUID.Random(); | ||
417 | child2Item.assetType = _rnd.Next(1, 1000); | ||
418 | child2Item.avatarID = _agent_1_id; | ||
419 | child2Item.creatorsID = LLUUID.Random(); | ||
420 | child2Item.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
421 | child2Item.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
422 | child2Item.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
423 | child2Item.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
424 | child2Item.inventoryID = LLUUID.Random(); | ||
425 | child2Item.inventoryDescription = "child2 item, Description"; | ||
426 | child2Item.inventoryName = "child2 item"; | ||
427 | child2Item.invType = _rnd.Next(1, 1000); | ||
428 | child2Item.parentFolderID = child2.folderID; | ||
429 | _dbPlugin.addInventoryItem(child2Item); | ||
430 | |||
431 | InventoryItemBase child2ChildItem = new InventoryItemBase(); | ||
432 | child2ChildItem.assetID = LLUUID.Random(); | ||
433 | child2ChildItem.assetType = _rnd.Next(1, 1000); | ||
434 | child2ChildItem.avatarID = _agent_1_id; | ||
435 | child2ChildItem.creatorsID = LLUUID.Random(); | ||
436 | child2ChildItem.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
437 | child2ChildItem.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
438 | child2ChildItem.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
439 | child2ChildItem.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
440 | child2ChildItem.inventoryID = LLUUID.Random(); | ||
441 | child2ChildItem.inventoryDescription = "child2Child item, Description"; | ||
442 | child2ChildItem.inventoryName = "child2Child item"; | ||
443 | child2ChildItem.invType = _rnd.Next(1, 1000); | ||
444 | child2ChildItem.parentFolderID = child2Child.folderID; | ||
445 | _dbPlugin.addInventoryItem(child2ChildItem); | ||
446 | |||
447 | // test read of items | ||
448 | |||
449 | InventoryItemBase item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
450 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
451 | |||
452 | item = _dbPlugin.getInventoryItem(child1Item.inventoryID); | ||
453 | Assert.IsTrue(AreItemsIdentical(child1Item, item)); | ||
454 | |||
455 | item = _dbPlugin.getInventoryItem(child1ChildItem.inventoryID); | ||
456 | Assert.IsTrue(AreItemsIdentical(child1ChildItem, item)); | ||
457 | |||
458 | item = _dbPlugin.getInventoryItem(child2Item.inventoryID); | ||
459 | Assert.IsTrue(AreItemsIdentical(child2Item, item)); | ||
460 | |||
461 | item = _dbPlugin.getInventoryItem(child2ChildItem.inventoryID); | ||
462 | Assert.IsTrue(AreItemsIdentical(child2ChildItem, item)); | ||
463 | |||
464 | _dbPlugin.deleteInventoryItem(rootItem.inventoryID); | ||
465 | _dbPlugin.deleteInventoryItem(child1Item.inventoryID); | ||
466 | _dbPlugin.deleteInventoryItem(child1ChildItem.inventoryID); | ||
467 | _dbPlugin.deleteInventoryItem(child2Item.inventoryID); | ||
468 | _dbPlugin.deleteInventoryItem(child2ChildItem.inventoryID); | ||
469 | } | ||
470 | |||
471 | /// <summary> | ||
472 | /// Test that we can insert a root folder | ||
473 | /// </summary> | ||
474 | [Test] | ||
475 | public void T07_DeleteInventoryWithItems() | ||
476 | { | ||
477 | |||
478 | // Setup inventory | ||
479 | InventoryFolderBase root = new InventoryFolderBase(); | ||
480 | root.agentID = _agent_1_id; | ||
481 | root.folderID = _agent_1_id; | ||
482 | root.name = "Root folder"; | ||
483 | root.parentID = LLUUID.Zero; | ||
484 | root.type = 2; | ||
485 | root.version = 2; | ||
486 | _dbPlugin.addInventoryFolder(root); | ||
487 | |||
488 | InventoryFolderBase child1 = new InventoryFolderBase(); | ||
489 | child1.agentID = _agent_1_id; | ||
490 | child1.folderID = LLUUID.Random(); | ||
491 | child1.name = "Child 1"; | ||
492 | child1.parentID = root.folderID; | ||
493 | child1.type = 3; | ||
494 | child1.version = 3; | ||
495 | _dbPlugin.addInventoryFolder(child1); | ||
496 | |||
497 | InventoryFolderBase child1Child = new InventoryFolderBase(); | ||
498 | child1Child.agentID = _agent_1_id; | ||
499 | child1Child.folderID = LLUUID.Random(); | ||
500 | child1Child.name = "Child 1 child"; | ||
501 | child1Child.parentID = child1.folderID; | ||
502 | child1Child.type = 4; | ||
503 | child1Child.version = 4; | ||
504 | _dbPlugin.addInventoryFolder(child1Child); | ||
505 | |||
506 | InventoryFolderBase child2 = new InventoryFolderBase(); | ||
507 | child2.agentID = _agent_1_id; | ||
508 | child2.folderID = LLUUID.Random(); | ||
509 | child2.name = "Child 2"; | ||
510 | child2.parentID = root.folderID; | ||
511 | child2.type = 5; | ||
512 | child2.version = 5; | ||
513 | _dbPlugin.addInventoryFolder(child2); | ||
514 | |||
515 | InventoryFolderBase child2Child = new InventoryFolderBase(); | ||
516 | child2Child.agentID = _agent_1_id; | ||
517 | child2Child.folderID = LLUUID.Random(); | ||
518 | child2Child.name = "Child 2 child"; | ||
519 | child2Child.parentID = child2.folderID; | ||
520 | child2Child.type = 6; | ||
521 | child2Child.version = 6; | ||
522 | _dbPlugin.addInventoryFolder(child2Child); | ||
523 | |||
524 | InventoryItemBase rootItem = new InventoryItemBase(); | ||
525 | rootItem.assetID = LLUUID.Random(); | ||
526 | rootItem.assetType = _rnd.Next(1, 1000); | ||
527 | rootItem.avatarID = _agent_1_id; | ||
528 | rootItem.creatorsID = LLUUID.Random(); | ||
529 | rootItem.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
530 | rootItem.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
531 | rootItem.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
532 | rootItem.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
533 | rootItem.inventoryID = LLUUID.Random(); | ||
534 | rootItem.inventoryDescription = "Root item, Description"; | ||
535 | rootItem.inventoryName = "Root item"; | ||
536 | rootItem.invType = _rnd.Next(1, 1000); | ||
537 | rootItem.parentFolderID = root.folderID; | ||
538 | _dbPlugin.addInventoryItem(rootItem); | ||
539 | |||
540 | InventoryItemBase child1Item = new InventoryItemBase(); | ||
541 | child1Item.assetID = LLUUID.Random(); | ||
542 | child1Item.assetType = _rnd.Next(1, 1000); | ||
543 | child1Item.avatarID = _agent_1_id; | ||
544 | child1Item.creatorsID = LLUUID.Random(); | ||
545 | child1Item.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
546 | child1Item.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
547 | child1Item.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
548 | child1Item.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
549 | child1Item.inventoryID = LLUUID.Random(); | ||
550 | child1Item.inventoryDescription = "child1 item, Description"; | ||
551 | child1Item.inventoryName = "child1 item"; | ||
552 | child1Item.invType = _rnd.Next(1, 1000); | ||
553 | child1Item.parentFolderID = child1.folderID; | ||
554 | _dbPlugin.addInventoryItem(child1Item); | ||
555 | |||
556 | InventoryItemBase child1ChildItem = new InventoryItemBase(); | ||
557 | child1ChildItem.assetID = LLUUID.Random(); | ||
558 | child1ChildItem.assetType = _rnd.Next(1, 1000); | ||
559 | child1ChildItem.avatarID = _agent_1_id; | ||
560 | child1ChildItem.creatorsID = LLUUID.Random(); | ||
561 | child1ChildItem.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
562 | child1ChildItem.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
563 | child1ChildItem.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
564 | child1ChildItem.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
565 | child1ChildItem.inventoryID = LLUUID.Random(); | ||
566 | child1ChildItem.inventoryDescription = "child1Child item, Description"; | ||
567 | child1ChildItem.inventoryName = "child1Child item"; | ||
568 | child1ChildItem.invType = _rnd.Next(1, 1000); | ||
569 | child1ChildItem.parentFolderID = child1Child.folderID; | ||
570 | _dbPlugin.addInventoryItem(child1ChildItem); | ||
571 | |||
572 | InventoryItemBase child2Item = new InventoryItemBase(); | ||
573 | child2Item.assetID = LLUUID.Random(); | ||
574 | child2Item.assetType = _rnd.Next(1, 1000); | ||
575 | child2Item.avatarID = _agent_1_id; | ||
576 | child2Item.creatorsID = LLUUID.Random(); | ||
577 | child2Item.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
578 | child2Item.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
579 | child2Item.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
580 | child2Item.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
581 | child2Item.inventoryID = LLUUID.Random(); | ||
582 | child2Item.inventoryDescription = "child2 item, Description"; | ||
583 | child2Item.inventoryName = "child2 item"; | ||
584 | child2Item.invType = _rnd.Next(1, 1000); | ||
585 | child2Item.parentFolderID = child2.folderID; | ||
586 | _dbPlugin.addInventoryItem(child2Item); | ||
587 | |||
588 | InventoryItemBase child2ChildItem = new InventoryItemBase(); | ||
589 | child2ChildItem.assetID = LLUUID.Random(); | ||
590 | child2ChildItem.assetType = _rnd.Next(1, 1000); | ||
591 | child2ChildItem.avatarID = _agent_1_id; | ||
592 | child2ChildItem.creatorsID = LLUUID.Random(); | ||
593 | child2ChildItem.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
594 | child2ChildItem.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
595 | child2ChildItem.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
596 | child2ChildItem.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
597 | child2ChildItem.inventoryID = LLUUID.Random(); | ||
598 | child2ChildItem.inventoryDescription = "child2Child item, Description"; | ||
599 | child2ChildItem.inventoryName = "child2Child item"; | ||
600 | child2ChildItem.invType = _rnd.Next(1, 1000); | ||
601 | child2ChildItem.parentFolderID = child2Child.folderID; | ||
602 | _dbPlugin.addInventoryItem(child2ChildItem); | ||
603 | |||
604 | // test deletetion of items | ||
605 | |||
606 | _dbPlugin.deleteInventoryItem(rootItem.inventoryID); | ||
607 | _dbPlugin.deleteInventoryItem(child1Item.inventoryID); | ||
608 | _dbPlugin.deleteInventoryItem(child1ChildItem.inventoryID); | ||
609 | _dbPlugin.deleteInventoryItem(child2Item.inventoryID); | ||
610 | _dbPlugin.deleteInventoryItem(child2ChildItem.inventoryID); | ||
611 | |||
612 | InventoryItemBase item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
613 | Assert.IsNull(item); | ||
614 | |||
615 | item = _dbPlugin.getInventoryItem(child1Item.inventoryID); | ||
616 | Assert.IsNull(item); | ||
617 | |||
618 | item = _dbPlugin.getInventoryItem(child1ChildItem.inventoryID); | ||
619 | Assert.IsNull(item); | ||
620 | |||
621 | item = _dbPlugin.getInventoryItem(child2Item.inventoryID); | ||
622 | Assert.IsNull(item); | ||
623 | |||
624 | item = _dbPlugin.getInventoryItem(child2ChildItem.inventoryID); | ||
625 | Assert.IsNull(item); | ||
626 | |||
627 | _dbPlugin.deleteInventoryFolder(_agent_1_id); | ||
628 | } | ||
629 | |||
630 | |||
631 | /// <summary> | ||
632 | /// Test that we can insert a root folder | ||
633 | /// </summary> | ||
634 | [Test] | ||
635 | public void T08_DeleteInventoryWithItems() | ||
636 | { | ||
637 | |||
638 | // Setup inventory | ||
639 | InventoryFolderBase root = new InventoryFolderBase(); | ||
640 | root.agentID = _agent_1_id; | ||
641 | root.folderID = _agent_1_id; | ||
642 | root.name = "Root folder"; | ||
643 | root.parentID = LLUUID.Zero; | ||
644 | root.type = 2; | ||
645 | root.version = 2; | ||
646 | _dbPlugin.addInventoryFolder(root); | ||
647 | |||
648 | InventoryFolderBase child1 = new InventoryFolderBase(); | ||
649 | child1.agentID = _agent_1_id; | ||
650 | child1.folderID = LLUUID.Random(); | ||
651 | child1.name = "Child 1"; | ||
652 | child1.parentID = root.folderID; | ||
653 | child1.type = 3; | ||
654 | child1.version = 3; | ||
655 | _dbPlugin.addInventoryFolder(child1); | ||
656 | |||
657 | InventoryFolderBase child1Child = new InventoryFolderBase(); | ||
658 | child1Child.agentID = _agent_1_id; | ||
659 | child1Child.folderID = LLUUID.Random(); | ||
660 | child1Child.name = "Child 1 child"; | ||
661 | child1Child.parentID = child1.folderID; | ||
662 | child1Child.type = 4; | ||
663 | child1Child.version = 4; | ||
664 | _dbPlugin.addInventoryFolder(child1Child); | ||
665 | |||
666 | InventoryFolderBase child2 = new InventoryFolderBase(); | ||
667 | child2.agentID = _agent_1_id; | ||
668 | child2.folderID = LLUUID.Random(); | ||
669 | child2.name = "Child 2"; | ||
670 | child2.parentID = root.folderID; | ||
671 | child2.type = 5; | ||
672 | child2.version = 5; | ||
673 | _dbPlugin.addInventoryFolder(child2); | ||
674 | |||
675 | InventoryFolderBase child2Child = new InventoryFolderBase(); | ||
676 | child2Child.agentID = _agent_1_id; | ||
677 | child2Child.folderID = LLUUID.Random(); | ||
678 | child2Child.name = "Child 2 child"; | ||
679 | child2Child.parentID = child2.folderID; | ||
680 | child2Child.type = 6; | ||
681 | child2Child.version = 6; | ||
682 | _dbPlugin.addInventoryFolder(child2Child); | ||
683 | |||
684 | InventoryItemBase rootItem = new InventoryItemBase(); | ||
685 | rootItem.assetID = LLUUID.Random(); | ||
686 | rootItem.assetType = _rnd.Next(1, 1000); | ||
687 | rootItem.avatarID = _agent_1_id; | ||
688 | rootItem.creatorsID = LLUUID.Random(); | ||
689 | rootItem.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
690 | rootItem.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
691 | rootItem.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
692 | rootItem.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
693 | rootItem.inventoryID = LLUUID.Random(); | ||
694 | rootItem.inventoryDescription = "Root item, Description"; | ||
695 | rootItem.inventoryName = "Root item"; | ||
696 | rootItem.invType = _rnd.Next(1, 1000); | ||
697 | rootItem.parentFolderID = root.folderID; | ||
698 | _dbPlugin.addInventoryItem(rootItem); | ||
699 | |||
700 | InventoryItemBase child1Item = new InventoryItemBase(); | ||
701 | child1Item.assetID = LLUUID.Random(); | ||
702 | child1Item.assetType = _rnd.Next(1, 1000); | ||
703 | child1Item.avatarID = _agent_1_id; | ||
704 | child1Item.creatorsID = LLUUID.Random(); | ||
705 | child1Item.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
706 | child1Item.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
707 | child1Item.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
708 | child1Item.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
709 | child1Item.inventoryID = LLUUID.Random(); | ||
710 | child1Item.inventoryDescription = "child1 item, Description"; | ||
711 | child1Item.inventoryName = "child1 item"; | ||
712 | child1Item.invType = _rnd.Next(1, 1000); | ||
713 | child1Item.parentFolderID = child1.folderID; | ||
714 | _dbPlugin.addInventoryItem(child1Item); | ||
715 | |||
716 | InventoryItemBase child1ChildItem = new InventoryItemBase(); | ||
717 | child1ChildItem.assetID = LLUUID.Random(); | ||
718 | child1ChildItem.assetType = _rnd.Next(1, 1000); | ||
719 | child1ChildItem.avatarID = _agent_1_id; | ||
720 | child1ChildItem.creatorsID = LLUUID.Random(); | ||
721 | child1ChildItem.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
722 | child1ChildItem.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
723 | child1ChildItem.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
724 | child1ChildItem.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
725 | child1ChildItem.inventoryID = LLUUID.Random(); | ||
726 | child1ChildItem.inventoryDescription = "child1Child item, Description"; | ||
727 | child1ChildItem.inventoryName = "child1Child item"; | ||
728 | child1ChildItem.invType = _rnd.Next(1, 1000); | ||
729 | child1ChildItem.parentFolderID = child1Child.folderID; | ||
730 | _dbPlugin.addInventoryItem(child1ChildItem); | ||
731 | |||
732 | InventoryItemBase child2Item = new InventoryItemBase(); | ||
733 | child2Item.assetID = LLUUID.Random(); | ||
734 | child2Item.assetType = _rnd.Next(1, 1000); | ||
735 | child2Item.avatarID = _agent_1_id; | ||
736 | child2Item.creatorsID = LLUUID.Random(); | ||
737 | child2Item.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
738 | child2Item.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
739 | child2Item.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
740 | child2Item.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
741 | child2Item.inventoryID = LLUUID.Random(); | ||
742 | child2Item.inventoryDescription = "child2 item, Description"; | ||
743 | child2Item.inventoryName = "child2 item"; | ||
744 | child2Item.invType = _rnd.Next(1, 1000); | ||
745 | child2Item.parentFolderID = child2.folderID; | ||
746 | _dbPlugin.addInventoryItem(child2Item); | ||
747 | |||
748 | InventoryItemBase child2ChildItem = new InventoryItemBase(); | ||
749 | child2ChildItem.assetID = LLUUID.Random(); | ||
750 | child2ChildItem.assetType = _rnd.Next(1, 1000); | ||
751 | child2ChildItem.avatarID = _agent_1_id; | ||
752 | child2ChildItem.creatorsID = LLUUID.Random(); | ||
753 | child2ChildItem.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
754 | child2ChildItem.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
755 | child2ChildItem.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
756 | child2ChildItem.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
757 | child2ChildItem.inventoryID = LLUUID.Random(); | ||
758 | child2ChildItem.inventoryDescription = "child2Child item, Description"; | ||
759 | child2ChildItem.inventoryName = "child2Child item"; | ||
760 | child2ChildItem.invType = _rnd.Next(1, 1000); | ||
761 | child2ChildItem.parentFolderID = child2Child.folderID; | ||
762 | _dbPlugin.addInventoryItem(child2ChildItem); | ||
763 | |||
764 | // test deletetion of items | ||
765 | |||
766 | _dbPlugin.deleteInventoryFolder(_agent_1_id); | ||
767 | |||
768 | InventoryItemBase item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
769 | Assert.IsNull(item); | ||
770 | |||
771 | item = _dbPlugin.getInventoryItem(child1Item.inventoryID); | ||
772 | Assert.IsNull(item); | ||
773 | |||
774 | item = _dbPlugin.getInventoryItem(child1ChildItem.inventoryID); | ||
775 | Assert.IsNull(item); | ||
776 | |||
777 | item = _dbPlugin.getInventoryItem(child2Item.inventoryID); | ||
778 | Assert.IsNull(item); | ||
779 | |||
780 | item = _dbPlugin.getInventoryItem(child2ChildItem.inventoryID); | ||
781 | Assert.IsNull(item); | ||
782 | |||
783 | } | ||
784 | |||
785 | /// <summary> | ||
786 | /// Test that we can update items | ||
787 | /// </summary> | ||
788 | [Test] | ||
789 | public void T09_UpdateItem() | ||
790 | { | ||
791 | |||
792 | // Setup inventory | ||
793 | InventoryFolderBase root = new InventoryFolderBase(); | ||
794 | root.agentID = _agent_1_id; | ||
795 | root.folderID = _agent_1_id; | ||
796 | root.name = "Root folder"; | ||
797 | root.parentID = LLUUID.Zero; | ||
798 | root.type = 2; | ||
799 | root.version = 2; | ||
800 | _dbPlugin.addInventoryFolder(root); | ||
801 | |||
802 | InventoryItemBase rootItem = new InventoryItemBase(); | ||
803 | rootItem.assetID = LLUUID.Random(); | ||
804 | rootItem.assetType = _rnd.Next(1, 1000); | ||
805 | rootItem.avatarID = _agent_1_id; | ||
806 | rootItem.creatorsID = LLUUID.Random(); | ||
807 | rootItem.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
808 | rootItem.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
809 | rootItem.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
810 | rootItem.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
811 | rootItem.inventoryID = LLUUID.Random(); | ||
812 | rootItem.inventoryDescription = "Root item, Description"; | ||
813 | rootItem.inventoryName = "Root item"; | ||
814 | rootItem.invType = _rnd.Next(1, 1000); | ||
815 | rootItem.parentFolderID = root.folderID; | ||
816 | _dbPlugin.addInventoryItem(rootItem); | ||
817 | |||
818 | rootItem.assetID = LLUUID.Random(); | ||
819 | _dbPlugin.updateInventoryItem(rootItem); | ||
820 | InventoryItemBase item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
821 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
822 | |||
823 | rootItem.assetType = rootItem.assetType+1; | ||
824 | _dbPlugin.updateInventoryItem(rootItem); | ||
825 | item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
826 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
827 | |||
828 | rootItem.avatarID = LLUUID.Random(); | ||
829 | _dbPlugin.updateInventoryItem(rootItem); | ||
830 | item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
831 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
832 | |||
833 | rootItem.creatorsID = LLUUID.Random(); | ||
834 | _dbPlugin.updateInventoryItem(rootItem); | ||
835 | item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
836 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
837 | |||
838 | rootItem.inventoryBasePermissions = rootItem.inventoryBasePermissions+1; | ||
839 | _dbPlugin.updateInventoryItem(rootItem); | ||
840 | item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
841 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
842 | |||
843 | rootItem.inventoryCurrentPermissions = rootItem.inventoryCurrentPermissions+1; | ||
844 | _dbPlugin.updateInventoryItem(rootItem); | ||
845 | item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
846 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
847 | |||
848 | rootItem.inventoryDescription = "New description"; | ||
849 | _dbPlugin.updateInventoryItem(rootItem); | ||
850 | item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
851 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
852 | |||
853 | rootItem.inventoryEveryOnePermissions = rootItem.inventoryEveryOnePermissions+1; | ||
854 | _dbPlugin.updateInventoryItem(rootItem); | ||
855 | item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
856 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
857 | |||
858 | rootItem.inventoryName = "New name"; | ||
859 | _dbPlugin.updateInventoryItem(rootItem); | ||
860 | item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
861 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
862 | |||
863 | rootItem.inventoryNextPermissions = rootItem.inventoryNextPermissions+1; | ||
864 | _dbPlugin.updateInventoryItem(rootItem); | ||
865 | item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
866 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
867 | |||
868 | rootItem.invType = rootItem.invType+1; | ||
869 | _dbPlugin.updateInventoryItem(rootItem); | ||
870 | item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
871 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
872 | |||
873 | rootItem.parentFolderID = LLUUID.Zero; | ||
874 | _dbPlugin.updateInventoryItem(rootItem); | ||
875 | item = _dbPlugin.getInventoryItem(rootItem.inventoryID); | ||
876 | Assert.IsTrue(AreItemsIdentical(rootItem, item)); | ||
877 | |||
878 | _dbPlugin.deleteInventoryFolder(_agent_1_id); | ||
879 | _dbPlugin.deleteInventoryItem(rootItem.inventoryID); | ||
880 | } | ||
881 | |||
882 | |||
883 | /// <summary> | ||
884 | /// Test that we can insert a root folder | ||
885 | /// </summary> | ||
886 | [Test] | ||
887 | public void T10_GetListOfItemsInFolder() | ||
888 | { | ||
889 | |||
890 | // Setup inventory | ||
891 | InventoryFolderBase root = new InventoryFolderBase(); | ||
892 | root.agentID = _agent_1_id; | ||
893 | root.folderID = _agent_1_id; | ||
894 | root.name = "Root folder"; | ||
895 | root.parentID = LLUUID.Zero; | ||
896 | root.type = 2; | ||
897 | root.version = 2; | ||
898 | _dbPlugin.addInventoryFolder(root); | ||
899 | |||
900 | InventoryFolderBase child1 = new InventoryFolderBase(); | ||
901 | child1.agentID = _agent_1_id; | ||
902 | child1.folderID = LLUUID.Random(); | ||
903 | child1.name = "Child 1"; | ||
904 | child1.parentID = root.folderID; | ||
905 | child1.type = 3; | ||
906 | child1.version = 3; | ||
907 | _dbPlugin.addInventoryFolder(child1); | ||
908 | |||
909 | InventoryFolderBase child1Child = new InventoryFolderBase(); | ||
910 | child1Child.agentID = _agent_1_id; | ||
911 | child1Child.folderID = LLUUID.Random(); | ||
912 | child1Child.name = "Child 1 child"; | ||
913 | child1Child.parentID = child1.folderID; | ||
914 | child1Child.type = 4; | ||
915 | child1Child.version = 4; | ||
916 | _dbPlugin.addInventoryFolder(child1Child); | ||
917 | |||
918 | |||
919 | InventoryItemBase item1 = new InventoryItemBase(); | ||
920 | item1.assetID = LLUUID.Random(); | ||
921 | item1.assetType = _rnd.Next(1, 1000); | ||
922 | item1.avatarID = _agent_1_id; | ||
923 | item1.creatorsID = LLUUID.Random(); | ||
924 | item1.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
925 | item1.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
926 | item1.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
927 | item1.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
928 | item1.inventoryID = LLUUID.Random(); | ||
929 | item1.inventoryDescription = "Item 1, description"; | ||
930 | item1.inventoryName = "Item 1"; | ||
931 | item1.invType = _rnd.Next(1, 1000); | ||
932 | item1.parentFolderID = child1Child.folderID; | ||
933 | _dbPlugin.addInventoryItem(item1); | ||
934 | |||
935 | InventoryItemBase item2 = new InventoryItemBase(); | ||
936 | item2.assetID = LLUUID.Random(); | ||
937 | item2.assetType = _rnd.Next(1, 1000); | ||
938 | item2.avatarID = _agent_1_id; | ||
939 | item2.creatorsID = LLUUID.Random(); | ||
940 | item2.inventoryBasePermissions = (uint)_rnd.Next(1, 1000000); | ||
941 | item2.inventoryCurrentPermissions = (uint)_rnd.Next(1, 1000000); | ||
942 | item2.inventoryEveryOnePermissions = (uint)_rnd.Next(1, 1000000); | ||
943 | item2.inventoryNextPermissions = (uint)_rnd.Next(1, 1000000); | ||
944 | item2.inventoryID = LLUUID.Random(); | ||
945 | item2.inventoryDescription = "Item 1, description"; | ||
946 | item2.inventoryName = "Item 1"; | ||
947 | item2.invType = _rnd.Next(1, 1000); | ||
948 | item2.parentFolderID = child1Child.folderID; | ||
949 | _dbPlugin.addInventoryItem(item2); | ||
950 | |||
951 | List<InventoryItemBase> items = _dbPlugin.getInventoryInFolder(child1Child.folderID); | ||
952 | Assert.IsNotNull(items); | ||
953 | Assert.IsNotEmpty(items); | ||
954 | |||
955 | bool foundItem1 = false; | ||
956 | bool foundItem2 = false; | ||
957 | |||
958 | foreach (InventoryItemBase i in items) | ||
959 | { | ||
960 | if (i.inventoryID == item1.inventoryID) | ||
961 | { | ||
962 | foundItem1 = true; | ||
963 | Assert.IsTrue(AreItemsIdentical(item1, i)); | ||
964 | } | ||
965 | else if (i.inventoryID == item2.inventoryID) | ||
966 | { | ||
967 | foundItem2 = true; | ||
968 | Assert.IsTrue(AreItemsIdentical(item2, i)); | ||
969 | } | ||
970 | else | ||
971 | { | ||
972 | Assert.Fail("Unknown inventory item found"); | ||
973 | } | ||
974 | } | ||
975 | |||
976 | Assert.IsTrue(foundItem1 && foundItem2, "not all items were returned"); | ||
977 | _dbPlugin.deleteInventoryFolder(_agent_1_id); | ||
978 | } | ||
979 | } | ||
980 | } | ||