TestInventory.cs 45 KB

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