29 using System.Collections.Generic;
31 using System.Reflection;
34 using NUnit.Framework;
36 using OpenSim.Framework;
37 using OpenSim.Services.Interfaces;
38 using OpenSim.Services.Connectors;
40 using OpenSim.Tests.Common;
42 namespace Robust.Tests
51 private UUID m_userID =
new UUID(
"00000000-0000-0000-0000-333333333333");
52 private UUID m_rootFolderID;
53 private UUID m_notecardsFolder;
54 private UUID m_objectsFolder;
59 TestHelpers.InMethod();
75 bool success = m_Connector.CreateUserInventory(m_userID);
76 Assert.IsTrue(success,
"Failed to create user inventory");
78 m_rootFolderID = m_Connector.GetRootFolder(m_userID).ID;
79 Assert.AreNotEqual(m_rootFolderID, UUID.Zero,
"Root folder ID must not be UUID.Zero");
82 Assert.IsNotNull(of,
"Failed to retrieve Objects folder");
83 m_objectsFolder = of.ID;
84 Assert.AreNotEqual(m_objectsFolder, UUID.Zero,
"Objects folder ID must not be UUID.Zero");
88 item.AssetID = UUID.Random();
89 item.AssetType = (int)AssetType.Object;
90 item.Folder = m_objectsFolder;
91 item.Name =
"Some Object";
92 item.Description =
string.Empty;
93 success = m_Connector.AddItem(item);
94 Assert.IsTrue(success,
"Failed to add object to inventory");
97 Assert.IsNotNull(of,
"Failed to retrieve Notecards folder");
98 m_notecardsFolder = ncf.ID;
99 Assert.AreNotEqual(m_notecardsFolder, UUID.Zero,
"Notecards folder ID must not be UUID.Zero");
100 m_notecardsFolder = ncf.ID;
103 item =
new InventoryItemBase(
new UUID(
"10000000-0000-0000-0000-000000000001"), m_userID);
104 item.AssetID = UUID.Random();
105 item.AssetType = (int)AssetType.Notecard;
106 item.Folder = m_notecardsFolder;
107 item.Name =
"Test Notecard 1";
108 item.Description =
string.Empty;
109 success = m_Connector.AddItem(item);
110 Assert.IsTrue(success,
"Failed to add Notecard 1 to inventory");
112 item.ID =
new UUID(
"20000000-0000-0000-0000-000000000002");
113 item.AssetID =
new UUID(
"a0000000-0000-0000-0000-00000000000a");
114 item.Name =
"Test Notecard 2";
115 item.Description = string.Empty;
116 success = m_Connector.AddItem(item);
117 Assert.IsTrue(success,
"Failed to add Notecard 2 to inventory");
121 folder.Type = (int)FolderType.None;
122 success = m_Connector.AddFolder(folder);
123 Assert.IsTrue(success,
"Failed to add Test Folder to inventory");
126 item.AssetID = item.ID;
127 item.ID =
new UUID(
"40000000-0000-0000-0000-000000000004");
128 item.AssetType = (int)AssetType.Link;
129 item.Folder = folder.ID;
130 item.Name =
"Link to notecard";
131 item.Description =
string.Empty;
132 success = m_Connector.AddItem(item);
133 Assert.IsTrue(success,
"Failed to add link to notecard to inventory");
136 item.AssetID = m_Connector.GetFolderForType(m_userID, FolderType.Object).ID;
137 item.ID =
new UUID(
"50000000-0000-0000-0000-000000000005");
138 item.AssetType = (int)AssetType.LinkFolder;
139 item.Folder = folder.ID;
140 item.Name =
"Link to Objects folder";
141 item.Description =
string.Empty;
142 success = m_Connector.AddItem(item);
143 Assert.IsTrue(success,
"Failed to add link to objects folder to inventory");
146 Assert.IsNotNull(coll,
"Failed to retrieve contents of root folder");
147 Assert.Greater(coll.Folders.Count, 0,
"Root folder does not have any subfolders");
149 coll = m_Connector.GetFolderContent(m_userID, folder.ID);
150 Assert.IsNotNull(coll,
"Failed to retrieve contents of Test Folder");
151 Assert.AreEqual(coll.Items.Count + coll.Folders.Count, 2,
"Test Folder is expected to have exactly 2 things inside");
158 TestHelpers.InMethod();
163 item = m_Connector.GetItem(item);
164 Assert.NotNull(item,
"Failed to get Notecard 1");
165 Assert.AreEqual(
"Test Notecard 1", item.Name,
"Wrong name for Notecard 1");
167 UUID[] uuids =
new UUID[2];
169 uuids[1] =
new UUID(
"20000000-0000-0000-0000-000000000002");
172 Assert.NotNull(items,
"Failed to get multiple items");
173 Assert.IsTrue(items.Length == 2,
"Requested 2 items, but didn't receive 2 items");
176 items = m_Connector.GetMultipleItems(m_userID, uuids);
177 Assert.NotNull(items,
"(Repeat) Failed to get multiple items");
178 Assert.IsTrue(items.Length == 2,
"(Repeat) Requested 2 items, but didn't receive 2 items");
181 uuids[1] =
new UUID(
"bb000000-0000-0000-0000-0000000000bb");
183 items = m_Connector.GetMultipleItems(m_userID, uuids);
184 Assert.NotNull(items,
"(Three times) Failed to get multiple items");
185 Assert.IsTrue(items.Length == 2,
"(Three times) Requested 2 items, but didn't receive 2 items");
186 Assert.AreEqual(
"Test Notecard 1", items[0].Name,
"(Three times) Wrong name for Notecard 1");
187 Assert.IsNull(items[1],
"(Three times) Expecting 2nd item to be null");
190 uuids[0] =
new UUID(
"aa000000-0000-0000-0000-0000000000aa");
191 items = m_Connector.GetMultipleItems(m_userID, uuids);
192 Assert.Null(items[0],
"Request to multiple non-existent items is supposed to return null [0]");
193 Assert.Null(items[1],
"Request to multiple non-existent items is supposed to return null [1]");
196 uuids[1] =
new UUID(
"b0000000-0000-0000-0000-00000000000b");
198 items = m_Connector.GetMultipleItems(m_userID, uuids);
199 Assert.NotNull(items,
"(Four times) Failed to get multiple items");
200 Assert.IsTrue(items.Length == 2,
"(Four times) Requested 2 items, but didn't receive 2 items");
201 Assert.AreEqual(
"Some Object", items[1].Name,
"(Four times) Wrong name for Some Object");
202 Assert.IsNull(items[0],
"(Four times) Expecting 1st item to be null");
void Inventory_001_CreateInventory()
Inventory Item - contains all the properties associated with an individual inventory piece...
void Inventory_002_MultipleItemsRequest()
Used to serialize a whole inventory for transfer over the network.