TestInventory.cs 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
  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. */
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Text;
  31. using NUnit.Framework;
  32. using libsecondlife;
  33. using OpenSim.Framework.Types;
  34. using OpenSim.Framework.Data;
  35. using OpenSim.Framework.Data.SQLite;
  36. using OpenSim.Framework.Data.MySQL;
  37. using OpenSim.Framework.Console;
  38. namespace OpenSim.Test.Inventory
  39. {
  40. [TestFixture]
  41. public class TestInventory
  42. {
  43. IInventoryData _dbPlugin;
  44. LLUUID _agent_1_id;
  45. public static LLUUID LibraryFolderRootUuid = new LLUUID("5926de2a-c2d7-4c11-ac4e-74512ffeb6d1");
  46. Random _rnd = new Random((int)DateTime.Now.Ticks);
  47. [TestFixtureSetUp]
  48. public void SetupInventoryTest()
  49. {
  50. _agent_1_id = LLUUID.Random();
  51. MainConsole.Instance = new ConsoleBase("TEST", null);
  52. // _dbPlugin = new SQLiteInventoryStore();
  53. _dbPlugin = new MySQLInventoryData();
  54. _dbPlugin.Initialise();
  55. }
  56. [TestFixtureTearDown]
  57. public void TeardownInventoryTest()
  58. {
  59. _dbPlugin.Close();
  60. }
  61. private bool AreFoldersIdentical(InventoryFolderBase a, InventoryFolderBase b)
  62. {
  63. if (a.agentID != b.agentID) return false;
  64. if (a.folderID != b.folderID) return false;
  65. if (a.name != b.name) return false;
  66. if (a.parentID != b.parentID) return false;
  67. if (a.type != b.type) return false;
  68. if (a.version != b.version) return false;
  69. return true;
  70. }
  71. private bool AreItemsIdentical(InventoryItemBase a, InventoryItemBase b)
  72. {
  73. if (a.assetID != b.assetID) return false;
  74. if (a.assetType != b.assetType) return false;
  75. if (a.avatarID != b.avatarID) return false;
  76. if (a.creatorsID != b.creatorsID) return false;
  77. if (a.inventoryBasePermissions != b.inventoryBasePermissions) return false;
  78. if (a.inventoryCurrentPermissions != b.inventoryCurrentPermissions) return false;
  79. if (a.inventoryEveryOnePermissions != b.inventoryEveryOnePermissions) return false;
  80. if (a.inventoryNextPermissions != b.inventoryNextPermissions) return false;
  81. if (a.inventoryID != b.inventoryID) return false;
  82. if (a.inventoryDescription != b.inventoryDescription) return false;
  83. if (a.inventoryName != b.inventoryName) return false;
  84. if (a.invType != b.invType) return false;
  85. if (a.parentFolderID != b.parentFolderID) return false;
  86. return true;
  87. }
  88. /// <summary>
  89. /// Test that we can insert a root folder
  90. /// </summary>
  91. [Test]
  92. public void T01_SetupRootFolder()
  93. {
  94. InventoryFolderBase root = new InventoryFolderBase();
  95. root.agentID = _agent_1_id;
  96. root.folderID = _agent_1_id;
  97. root.name = "Root folder";
  98. root.parentID = LLUUID.Zero;
  99. root.type = 2;
  100. root.version = 2;
  101. _dbPlugin.addInventoryFolder(root);
  102. InventoryFolderBase f = _dbPlugin.getInventoryFolder(root.folderID);
  103. Assert.IsNotNull(f, "Failed to get existing folder");
  104. Assert.IsTrue(AreFoldersIdentical(root, f), "Difference between stored and retrieved folder data");
  105. // Test that we only get the root folder, based on it's id, i.e. any other gui will not find the folder
  106. f = _dbPlugin.getInventoryFolder(LLUUID.Zero);
  107. Assert.IsNull(f, "get folder returned a folder, but shouldn't find one");
  108. f = _dbPlugin.getInventoryFolder(LLUUID.Random());
  109. Assert.IsNull(f, "get folder returned a folder, but shouldn't find one");
  110. // test that we can delete the folder
  111. _dbPlugin.deleteInventoryFolder(_agent_1_id);
  112. f = _dbPlugin.getInventoryFolder(root.folderID);
  113. Assert.IsNull(f, "get folder returned a folder, but it should have been deleted");
  114. }
  115. /// <summary>
  116. /// Make sure that all folders reported as root folders are root folders
  117. /// </summary>
  118. [Test]
  119. public void T02_TestRootFolder()
  120. {
  121. InventoryFolderBase root = new InventoryFolderBase();
  122. root.agentID = _agent_1_id;
  123. root.folderID = _agent_1_id;
  124. root.name = "Root folder";
  125. root.parentID = LLUUID.Zero;
  126. root.type = 2;
  127. root.version = 2;
  128. _dbPlugin.addInventoryFolder(root);
  129. List<InventoryFolderBase> folders = _dbPlugin.getUserRootFolders(_agent_1_id);
  130. Assert.IsNotNull(folders, "Failed to get rootfolders for user");
  131. bool foundRoot = false;
  132. foreach(InventoryFolderBase f in folders) {
  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. }