TestInventory.cs 45 KB

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