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