diff options
Diffstat (limited to 'OpenSim/Data/Tests/RegionTests.cs')
-rw-r--r-- | OpenSim/Data/Tests/RegionTests.cs | 1140 |
1 files changed, 1140 insertions, 0 deletions
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs new file mode 100644 index 0000000..1b93176 --- /dev/null +++ b/OpenSim/Data/Tests/RegionTests.cs | |||
@@ -0,0 +1,1140 @@ | |||
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 OpenSimulator 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.Drawing; | ||
31 | using System.Text; | ||
32 | using log4net.Config; | ||
33 | using NUnit.Framework; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Tests.Common; | ||
39 | using log4net; | ||
40 | using System.Reflection; | ||
41 | using System.Data.Common; | ||
42 | |||
43 | // DBMS-specific: | ||
44 | using MySql.Data.MySqlClient; | ||
45 | using OpenSim.Data.MySQL; | ||
46 | |||
47 | using System.Data.SqlClient; | ||
48 | using OpenSim.Data.MSSQL; | ||
49 | |||
50 | using Mono.Data.Sqlite; | ||
51 | using OpenSim.Data.SQLite; | ||
52 | |||
53 | namespace OpenSim.Data.Tests | ||
54 | { | ||
55 | [TestFixture(Description = "Region store tests (SQLite)")] | ||
56 | public class SQLiteRegionTests : RegionTests<SqliteConnection, SQLiteSimulationData> | ||
57 | { | ||
58 | } | ||
59 | |||
60 | [TestFixture(Description = "Region store tests (MySQL)")] | ||
61 | public class MySqlRegionTests : RegionTests<MySqlConnection, MySQLSimulationData> | ||
62 | { | ||
63 | } | ||
64 | |||
65 | [TestFixture(Description = "Region store tests (MS SQL Server)")] | ||
66 | public class MSSQLRegionTests : RegionTests<SqlConnection, MSSQLSimulationData> | ||
67 | { | ||
68 | } | ||
69 | |||
70 | public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore> | ||
71 | where TConn : DbConnection, new() | ||
72 | where TRegStore : class, ISimulationDataStore, new() | ||
73 | { | ||
74 | bool m_rebuildDB; | ||
75 | |||
76 | public ISimulationDataStore db; | ||
77 | public UUID zero = UUID.Zero; | ||
78 | public UUID region1 = UUID.Random(); | ||
79 | public UUID region2 = UUID.Random(); | ||
80 | public UUID region3 = UUID.Random(); | ||
81 | public UUID region4 = UUID.Random(); | ||
82 | public UUID prim1 = UUID.Random(); | ||
83 | public UUID prim2 = UUID.Random(); | ||
84 | public UUID prim3 = UUID.Random(); | ||
85 | public UUID prim4 = UUID.Random(); | ||
86 | public UUID prim5 = UUID.Random(); | ||
87 | public UUID prim6 = UUID.Random(); | ||
88 | public UUID item1 = UUID.Random(); | ||
89 | public UUID item2 = UUID.Random(); | ||
90 | public UUID item3 = UUID.Random(); | ||
91 | |||
92 | public static Random random = new Random(); | ||
93 | |||
94 | public string itemname1 = "item1"; | ||
95 | |||
96 | public uint localID = 1; | ||
97 | |||
98 | public double height1 = 20; | ||
99 | public double height2 = 100; | ||
100 | |||
101 | public RegionTests(string conn, bool rebuild) | ||
102 | : base(conn) | ||
103 | { | ||
104 | m_rebuildDB = rebuild; | ||
105 | } | ||
106 | |||
107 | public RegionTests() : this("", true) { } | ||
108 | public RegionTests(string conn) : this(conn, true) {} | ||
109 | public RegionTests(bool rebuild): this("", rebuild) {} | ||
110 | |||
111 | |||
112 | protected override void InitService(object service) | ||
113 | { | ||
114 | ClearDB(); | ||
115 | db = (ISimulationDataStore)service; | ||
116 | db.Initialise(m_connStr); | ||
117 | } | ||
118 | |||
119 | private void ClearDB() | ||
120 | { | ||
121 | string[] reg_tables = new string[] { | ||
122 | "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings" | ||
123 | }; | ||
124 | |||
125 | if (m_rebuildDB) | ||
126 | { | ||
127 | DropTables(reg_tables); | ||
128 | ResetMigrations("RegionStore"); | ||
129 | } | ||
130 | else | ||
131 | { | ||
132 | ClearTables(reg_tables); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | // Test Plan | ||
137 | // Prims | ||
138 | // - empty test - 001 | ||
139 | // - store / retrieve basic prims (most minimal we can make) - 010, 011 | ||
140 | // - store / retrieve parts in a scenegroup 012 | ||
141 | // - store a prim with complete information for consistency check 013 | ||
142 | // - update existing prims, make sure it sticks - 014 | ||
143 | // - tests empty inventory - 020 | ||
144 | // - add inventory items to prims make - 021 | ||
145 | // - retrieves the added item - 022 | ||
146 | // - update inventory items to prims - 023 | ||
147 | // - remove inventory items make sure it sticks - 024 | ||
148 | // - checks if all parameters are persistent - 025 | ||
149 | // - adds many items and see if it is handled correctly - 026 | ||
150 | |||
151 | [Test] | ||
152 | public void T001_LoadEmpty() | ||
153 | { | ||
154 | TestHelpers.InMethod(); | ||
155 | |||
156 | List<SceneObjectGroup> objs = db.LoadObjects(region1); | ||
157 | List<SceneObjectGroup> objs3 = db.LoadObjects(region3); | ||
158 | List<LandData> land = db.LoadLandObjects(region1); | ||
159 | |||
160 | Assert.That(objs.Count, Is.EqualTo(0), "Assert.That(objs.Count, Is.EqualTo(0))"); | ||
161 | Assert.That(objs3.Count, Is.EqualTo(0), "Assert.That(objs3.Count, Is.EqualTo(0))"); | ||
162 | Assert.That(land.Count, Is.EqualTo(0), "Assert.That(land.Count, Is.EqualTo(0))"); | ||
163 | } | ||
164 | |||
165 | // SOG round trips | ||
166 | // * store objects, make sure they save | ||
167 | // * update | ||
168 | |||
169 | [Test] | ||
170 | public void T010_StoreSimpleObject() | ||
171 | { | ||
172 | TestHelpers.InMethod(); | ||
173 | |||
174 | SceneObjectGroup sog = NewSOG("object1", prim1, region1); | ||
175 | SceneObjectGroup sog2 = NewSOG("object2", prim2, region1); | ||
176 | |||
177 | // in case the objects don't store | ||
178 | try | ||
179 | { | ||
180 | db.StoreObject(sog, region1); | ||
181 | } | ||
182 | catch (Exception e) | ||
183 | { | ||
184 | m_log.Error(e.ToString()); | ||
185 | Assert.Fail(); | ||
186 | } | ||
187 | |||
188 | try | ||
189 | { | ||
190 | db.StoreObject(sog2, region1); | ||
191 | } | ||
192 | catch (Exception e) | ||
193 | { | ||
194 | m_log.Error(e.ToString()); | ||
195 | Assert.Fail(); | ||
196 | } | ||
197 | |||
198 | // This tests the ADO.NET driver | ||
199 | List<SceneObjectGroup> objs = db.LoadObjects(region1); | ||
200 | |||
201 | Assert.That(objs.Count, Is.EqualTo(2), "Assert.That(objs.Count, Is.EqualTo(2))"); | ||
202 | } | ||
203 | |||
204 | [Test] | ||
205 | public void T011_ObjectNames() | ||
206 | { | ||
207 | TestHelpers.InMethod(); | ||
208 | |||
209 | List<SceneObjectGroup> objs = db.LoadObjects(region1); | ||
210 | foreach (SceneObjectGroup sog in objs) | ||
211 | { | ||
212 | SceneObjectPart p = sog.RootPart; | ||
213 | Assert.That("", Is.Not.EqualTo(p.Name), "Assert.That(\"\", Is.Not.EqualTo(p.Name))"); | ||
214 | Assert.That(p.Name, Is.EqualTo(p.Description), "Assert.That(p.Name, Is.EqualTo(p.Description))"); | ||
215 | } | ||
216 | } | ||
217 | |||
218 | [Test] | ||
219 | public void T012_SceneParts() | ||
220 | { | ||
221 | TestHelpers.InMethod(); | ||
222 | |||
223 | UUID tmp0 = UUID.Random(); | ||
224 | UUID tmp1 = UUID.Random(); | ||
225 | UUID tmp2 = UUID.Random(); | ||
226 | UUID tmp3 = UUID.Random(); | ||
227 | UUID newregion = UUID.Random(); | ||
228 | SceneObjectPart p1 = NewSOP("SoP 1",tmp1); | ||
229 | SceneObjectPart p2 = NewSOP("SoP 2",tmp2); | ||
230 | SceneObjectPart p3 = NewSOP("SoP 3",tmp3); | ||
231 | SceneObjectGroup sog = NewSOG("Sop 0", tmp0, newregion); | ||
232 | sog.AddPart(p1); | ||
233 | sog.AddPart(p2); | ||
234 | sog.AddPart(p3); | ||
235 | |||
236 | SceneObjectPart[] parts = sog.Parts; | ||
237 | Assert.That(parts.Length,Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))"); | ||
238 | |||
239 | db.StoreObject(sog, newregion); | ||
240 | List<SceneObjectGroup> sogs = db.LoadObjects(newregion); | ||
241 | Assert.That(sogs.Count,Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))"); | ||
242 | SceneObjectGroup newsog = sogs[0]; | ||
243 | |||
244 | SceneObjectPart[] newparts = newsog.Parts; | ||
245 | Assert.That(newparts.Length,Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))"); | ||
246 | |||
247 | Assert.That(newsog.HasChildPrim(tmp0), "Assert.That(newsog.HasChildPrim(tmp0))"); | ||
248 | Assert.That(newsog.HasChildPrim(tmp1), "Assert.That(newsog.HasChildPrim(tmp1))"); | ||
249 | Assert.That(newsog.HasChildPrim(tmp2), "Assert.That(newsog.HasChildPrim(tmp2))"); | ||
250 | Assert.That(newsog.HasChildPrim(tmp3), "Assert.That(newsog.HasChildPrim(tmp3))"); | ||
251 | } | ||
252 | |||
253 | [Test] | ||
254 | public void T013_DatabasePersistency() | ||
255 | { | ||
256 | TestHelpers.InMethod(); | ||
257 | |||
258 | // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data | ||
259 | // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored | ||
260 | // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently. | ||
261 | UUID creator,uuid = new UUID(); | ||
262 | creator = UUID.Random(); | ||
263 | uint iserial = (uint)random.Next(); | ||
264 | TaskInventoryDictionary dic = new TaskInventoryDictionary(); | ||
265 | uint objf = (uint) random.Next(); | ||
266 | uuid = prim4; | ||
267 | uint localid = localID+1; | ||
268 | localID = localID + 1; | ||
269 | string name = "Adam West"; | ||
270 | byte material = (byte) random.Next(127); | ||
271 | ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next(); | ||
272 | int pin = random.Next(); | ||
273 | Byte[] partsys = new byte[8]; | ||
274 | Byte[] textani = new byte[8]; | ||
275 | random.NextBytes(textani); | ||
276 | random.NextBytes(partsys); | ||
277 | DateTime expires = new DateTime(2008, 12, 20); | ||
278 | DateTime rezzed = new DateTime(2009, 07, 15); | ||
279 | Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next()); | ||
280 | Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next()); | ||
281 | Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next()); | ||
282 | Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next()); | ||
283 | Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next()); | ||
284 | Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next()); | ||
285 | string description = name; | ||
286 | Color color = Color.FromArgb(255, 165, 50, 100); | ||
287 | string text = "All Your Base Are Belong to Us"; | ||
288 | string sitname = "SitName"; | ||
289 | string touchname = "TouchName"; | ||
290 | int linknum = random.Next(); | ||
291 | byte clickaction = (byte) random.Next(127); | ||
292 | PrimitiveBaseShape pbshap = new PrimitiveBaseShape(); | ||
293 | pbshap = PrimitiveBaseShape.Default; | ||
294 | pbshap.PathBegin = ushort.MaxValue; | ||
295 | pbshap.PathEnd = ushort.MaxValue; | ||
296 | pbshap.ProfileBegin = ushort.MaxValue; | ||
297 | pbshap.ProfileEnd = ushort.MaxValue; | ||
298 | pbshap.ProfileHollow = ushort.MaxValue; | ||
299 | Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); | ||
300 | |||
301 | RegionInfo regionInfo = new RegionInfo(); | ||
302 | regionInfo.RegionID = region3; | ||
303 | regionInfo.RegionLocX = 0; | ||
304 | regionInfo.RegionLocY = 0; | ||
305 | |||
306 | SceneObjectPart sop = new SceneObjectPart(); | ||
307 | SceneObjectGroup sog = new SceneObjectGroup(sop); | ||
308 | |||
309 | sop.RegionHandle = regionh; | ||
310 | sop.UUID = uuid; | ||
311 | sop.LocalId = localid; | ||
312 | sop.Shape = pbshap; | ||
313 | sop.GroupPosition = groupos; | ||
314 | sop.RotationOffset = rotoff; | ||
315 | sop.CreatorID = creator; | ||
316 | sop.InventorySerial = iserial; | ||
317 | sop.TaskInventory = dic; | ||
318 | sop.Flags = (PrimFlags)objf; | ||
319 | sop.Name = name; | ||
320 | sop.Material = material; | ||
321 | sop.ScriptAccessPin = pin; | ||
322 | sop.TextureAnimation = textani; | ||
323 | sop.ParticleSystem = partsys; | ||
324 | sop.Expires = expires; | ||
325 | sop.Rezzed = rezzed; | ||
326 | sop.OffsetPosition = offset; | ||
327 | sop.Velocity = velocity; | ||
328 | sop.AngularVelocity = angvelo; | ||
329 | sop.Acceleration = accel; | ||
330 | sop.Description = description; | ||
331 | sop.Color = color; | ||
332 | sop.Text = text; | ||
333 | sop.SitName = sitname; | ||
334 | sop.TouchName = touchname; | ||
335 | sop.LinkNum = linknum; | ||
336 | sop.ClickAction = clickaction; | ||
337 | sop.Scale = scale; | ||
338 | |||
339 | //Tests if local part accepted the parameters: | ||
340 | Assert.That(regionh,Is.EqualTo(sop.RegionHandle), "Assert.That(regionh,Is.EqualTo(sop.RegionHandle))"); | ||
341 | Assert.That(localid,Is.EqualTo(sop.LocalId), "Assert.That(localid,Is.EqualTo(sop.LocalId))"); | ||
342 | Assert.That(groupos,Is.EqualTo(sop.GroupPosition), "Assert.That(groupos,Is.EqualTo(sop.GroupPosition))"); | ||
343 | Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))"); | ||
344 | Assert.That(rotoff,Is.EqualTo(sop.RotationOffset), "Assert.That(rotoff,Is.EqualTo(sop.RotationOffset))"); | ||
345 | Assert.That(uuid,Is.EqualTo(sop.UUID), "Assert.That(uuid,Is.EqualTo(sop.UUID))"); | ||
346 | Assert.That(creator,Is.EqualTo(sop.CreatorID), "Assert.That(creator,Is.EqualTo(sop.CreatorID))"); | ||
347 | // Modified in-class | ||
348 | // Assert.That(iserial,Is.EqualTo(sop.InventorySerial), "Assert.That(iserial,Is.EqualTo(sop.InventorySerial))"); | ||
349 | Assert.That(dic,Is.EqualTo(sop.TaskInventory), "Assert.That(dic,Is.EqualTo(sop.TaskInventory))"); | ||
350 | Assert.That(objf, Is.EqualTo((uint)sop.Flags), "Assert.That(objf,Is.EqualTo(sop.Flags))"); | ||
351 | Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))"); | ||
352 | Assert.That(material,Is.EqualTo(sop.Material), "Assert.That(material,Is.EqualTo(sop.Material))"); | ||
353 | Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin))"); | ||
354 | Assert.That(textani,Is.EqualTo(sop.TextureAnimation), "Assert.That(textani,Is.EqualTo(sop.TextureAnimation))"); | ||
355 | Assert.That(partsys,Is.EqualTo(sop.ParticleSystem), "Assert.That(partsys,Is.EqualTo(sop.ParticleSystem))"); | ||
356 | Assert.That(expires,Is.EqualTo(sop.Expires), "Assert.That(expires,Is.EqualTo(sop.Expires))"); | ||
357 | Assert.That(rezzed,Is.EqualTo(sop.Rezzed), "Assert.That(rezzed,Is.EqualTo(sop.Rezzed))"); | ||
358 | Assert.That(offset,Is.EqualTo(sop.OffsetPosition), "Assert.That(offset,Is.EqualTo(sop.OffsetPosition))"); | ||
359 | Assert.That(velocity,Is.EqualTo(sop.Velocity), "Assert.That(velocity,Is.EqualTo(sop.Velocity))"); | ||
360 | Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity))"); | ||
361 | Assert.That(accel,Is.EqualTo(sop.Acceleration), "Assert.That(accel,Is.EqualTo(sop.Acceleration))"); | ||
362 | Assert.That(description,Is.EqualTo(sop.Description), "Assert.That(description,Is.EqualTo(sop.Description))"); | ||
363 | Assert.That(color,Is.EqualTo(sop.Color), "Assert.That(color,Is.EqualTo(sop.Color))"); | ||
364 | Assert.That(text,Is.EqualTo(sop.Text), "Assert.That(text,Is.EqualTo(sop.Text))"); | ||
365 | Assert.That(sitname,Is.EqualTo(sop.SitName), "Assert.That(sitname,Is.EqualTo(sop.SitName))"); | ||
366 | Assert.That(touchname,Is.EqualTo(sop.TouchName), "Assert.That(touchname,Is.EqualTo(sop.TouchName))"); | ||
367 | Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))"); | ||
368 | Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))"); | ||
369 | Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))"); | ||
370 | |||
371 | // This is necessary or object will not be inserted in DB | ||
372 | sop.Flags = PrimFlags.None; | ||
373 | |||
374 | // Inserts group in DB | ||
375 | db.StoreObject(sog,region3); | ||
376 | List<SceneObjectGroup> sogs = db.LoadObjects(region3); | ||
377 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); | ||
378 | // Makes sure there are no double insertions: | ||
379 | db.StoreObject(sog,region3); | ||
380 | sogs = db.LoadObjects(region3); | ||
381 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); | ||
382 | |||
383 | |||
384 | // Tests if the parameters were inserted correctly | ||
385 | SceneObjectPart p = sogs[0].RootPart; | ||
386 | Assert.That(regionh,Is.EqualTo(p.RegionHandle), "Assert.That(regionh,Is.EqualTo(p.RegionHandle))"); | ||
387 | //Assert.That(localid,Is.EqualTo(p.LocalId), "Assert.That(localid,Is.EqualTo(p.LocalId))"); | ||
388 | Assert.That(groupos,Is.EqualTo(p.GroupPosition), "Assert.That(groupos,Is.EqualTo(p.GroupPosition))"); | ||
389 | Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); | ||
390 | Assert.That(rotoff,Is.EqualTo(p.RotationOffset), "Assert.That(rotoff,Is.EqualTo(p.RotationOffset))"); | ||
391 | Assert.That(uuid,Is.EqualTo(p.UUID), "Assert.That(uuid,Is.EqualTo(p.UUID))"); | ||
392 | Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))"); | ||
393 | //Assert.That(iserial,Is.EqualTo(p.InventorySerial), "Assert.That(iserial,Is.EqualTo(p.InventorySerial))"); | ||
394 | Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))"); | ||
395 | //Assert.That(objf, Is.EqualTo((uint)p.Flags), "Assert.That(objf,Is.EqualTo(p.Flags))"); | ||
396 | Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); | ||
397 | Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))"); | ||
398 | Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))"); | ||
399 | Assert.That(textani,Is.EqualTo(p.TextureAnimation), "Assert.That(textani,Is.EqualTo(p.TextureAnimation))"); | ||
400 | Assert.That(partsys,Is.EqualTo(p.ParticleSystem), "Assert.That(partsys,Is.EqualTo(p.ParticleSystem))"); | ||
401 | //Assert.That(expires,Is.EqualTo(p.Expires), "Assert.That(expires,Is.EqualTo(p.Expires))"); | ||
402 | //Assert.That(rezzed,Is.EqualTo(p.Rezzed), "Assert.That(rezzed,Is.EqualTo(p.Rezzed))"); | ||
403 | Assert.That(offset,Is.EqualTo(p.OffsetPosition), "Assert.That(offset,Is.EqualTo(p.OffsetPosition))"); | ||
404 | Assert.That(velocity,Is.EqualTo(p.Velocity), "Assert.That(velocity,Is.EqualTo(p.Velocity))"); | ||
405 | Assert.That(angvelo,Is.EqualTo(p.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))"); | ||
406 | Assert.That(accel,Is.EqualTo(p.Acceleration), "Assert.That(accel,Is.EqualTo(p.Acceleration))"); | ||
407 | Assert.That(description,Is.EqualTo(p.Description), "Assert.That(description,Is.EqualTo(p.Description))"); | ||
408 | Assert.That(color,Is.EqualTo(p.Color), "Assert.That(color,Is.EqualTo(p.Color))"); | ||
409 | Assert.That(text,Is.EqualTo(p.Text), "Assert.That(text,Is.EqualTo(p.Text))"); | ||
410 | Assert.That(sitname,Is.EqualTo(p.SitName), "Assert.That(sitname,Is.EqualTo(p.SitName))"); | ||
411 | Assert.That(touchname,Is.EqualTo(p.TouchName), "Assert.That(touchname,Is.EqualTo(p.TouchName))"); | ||
412 | //Assert.That(linknum,Is.EqualTo(p.LinkNum), "Assert.That(linknum,Is.EqualTo(p.LinkNum))"); | ||
413 | Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); | ||
414 | Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); | ||
415 | |||
416 | //Assert.That(updatef,Is.EqualTo(p.UpdateFlag), "Assert.That(updatef,Is.EqualTo(p.UpdateFlag))"); | ||
417 | |||
418 | Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin), "Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin))"); | ||
419 | Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd), "Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd))"); | ||
420 | Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin), "Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin))"); | ||
421 | Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd), "Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd))"); | ||
422 | Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow), "Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow))"); | ||
423 | } | ||
424 | |||
425 | [Test] | ||
426 | public void T014_UpdateObject() | ||
427 | { | ||
428 | TestHelpers.InMethod(); | ||
429 | |||
430 | string text1 = "object1 text"; | ||
431 | SceneObjectGroup sog = FindSOG("object1", region1); | ||
432 | sog.RootPart.Text = text1; | ||
433 | db.StoreObject(sog, region1); | ||
434 | |||
435 | sog = FindSOG("object1", region1); | ||
436 | Assert.That(text1, Is.EqualTo(sog.RootPart.Text), "Assert.That(text1, Is.EqualTo(sog.RootPart.Text))"); | ||
437 | |||
438 | // Creates random values | ||
439 | UUID creator = new UUID(); | ||
440 | creator = UUID.Random(); | ||
441 | TaskInventoryDictionary dic = new TaskInventoryDictionary(); | ||
442 | localID = localID + 1; | ||
443 | string name = "West Adam"; | ||
444 | byte material = (byte) random.Next(127); | ||
445 | ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next(); | ||
446 | int pin = random.Next(); | ||
447 | Byte[] partsys = new byte[8]; | ||
448 | Byte[] textani = new byte[8]; | ||
449 | random.NextBytes(textani); | ||
450 | random.NextBytes(partsys); | ||
451 | DateTime expires = new DateTime(2010, 12, 20); | ||
452 | DateTime rezzed = new DateTime(2005, 07, 15); | ||
453 | Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next()); | ||
454 | Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next()); | ||
455 | Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next()); | ||
456 | Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next()); | ||
457 | Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next()); | ||
458 | Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next()); | ||
459 | string description = name; | ||
460 | Color color = Color.FromArgb(255, 255, 255, 0); | ||
461 | string text = "What You Say?{]\vz~"; | ||
462 | string sitname = RandomName(); | ||
463 | string touchname = RandomName(); | ||
464 | int linknum = random.Next(); | ||
465 | byte clickaction = (byte) random.Next(127); | ||
466 | PrimitiveBaseShape pbshap = new PrimitiveBaseShape(); | ||
467 | pbshap = PrimitiveBaseShape.Default; | ||
468 | Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); | ||
469 | |||
470 | // Updates the region with new values | ||
471 | SceneObjectGroup sog2 = FindSOG("Adam West", region3); | ||
472 | Assert.That(sog2,Is.Not.Null); | ||
473 | sog2.RootPart.RegionHandle = regionh; | ||
474 | sog2.RootPart.Shape = pbshap; | ||
475 | sog2.RootPart.GroupPosition = groupos; | ||
476 | sog2.RootPart.RotationOffset = rotoff; | ||
477 | sog2.RootPart.CreatorID = creator; | ||
478 | sog2.RootPart.TaskInventory = dic; | ||
479 | sog2.RootPart.Name = name; | ||
480 | sog2.RootPart.Material = material; | ||
481 | sog2.RootPart.ScriptAccessPin = pin; | ||
482 | sog2.RootPart.TextureAnimation = textani; | ||
483 | sog2.RootPart.ParticleSystem = partsys; | ||
484 | sog2.RootPart.Expires = expires; | ||
485 | sog2.RootPart.Rezzed = rezzed; | ||
486 | sog2.RootPart.OffsetPosition = offset; | ||
487 | sog2.RootPart.Velocity = velocity; | ||
488 | sog2.RootPart.AngularVelocity = angvelo; | ||
489 | sog2.RootPart.Acceleration = accel; | ||
490 | sog2.RootPart.Description = description; | ||
491 | sog2.RootPart.Color = color; | ||
492 | sog2.RootPart.Text = text; | ||
493 | sog2.RootPart.SitName = sitname; | ||
494 | sog2.RootPart.TouchName = touchname; | ||
495 | sog2.RootPart.LinkNum = linknum; | ||
496 | sog2.RootPart.ClickAction = clickaction; | ||
497 | sog2.RootPart.Scale = scale; | ||
498 | |||
499 | db.StoreObject(sog2, region3); | ||
500 | List<SceneObjectGroup> sogs = db.LoadObjects(region3); | ||
501 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); | ||
502 | |||
503 | SceneObjectGroup retsog = FindSOG("West Adam", region3); | ||
504 | Assert.That(retsog,Is.Not.Null); | ||
505 | SceneObjectPart p = retsog.RootPart; | ||
506 | Assert.That(regionh,Is.EqualTo(p.RegionHandle), "Assert.That(regionh,Is.EqualTo(p.RegionHandle))"); | ||
507 | Assert.That(groupos,Is.EqualTo(p.GroupPosition), "Assert.That(groupos,Is.EqualTo(p.GroupPosition))"); | ||
508 | Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); | ||
509 | Assert.That(rotoff,Is.EqualTo(p.RotationOffset), "Assert.That(rotoff,Is.EqualTo(p.RotationOffset))"); | ||
510 | Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))"); | ||
511 | Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))"); | ||
512 | Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); | ||
513 | Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))"); | ||
514 | Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))"); | ||
515 | Assert.That(textani,Is.EqualTo(p.TextureAnimation), "Assert.That(textani,Is.EqualTo(p.TextureAnimation))"); | ||
516 | Assert.That(partsys,Is.EqualTo(p.ParticleSystem), "Assert.That(partsys,Is.EqualTo(p.ParticleSystem))"); | ||
517 | Assert.That(offset,Is.EqualTo(p.OffsetPosition), "Assert.That(offset,Is.EqualTo(p.OffsetPosition))"); | ||
518 | Assert.That(velocity,Is.EqualTo(p.Velocity), "Assert.That(velocity,Is.EqualTo(p.Velocity))"); | ||
519 | Assert.That(angvelo,Is.EqualTo(p.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))"); | ||
520 | Assert.That(accel,Is.EqualTo(p.Acceleration), "Assert.That(accel,Is.EqualTo(p.Acceleration))"); | ||
521 | Assert.That(description,Is.EqualTo(p.Description), "Assert.That(description,Is.EqualTo(p.Description))"); | ||
522 | Assert.That(color,Is.EqualTo(p.Color), "Assert.That(color,Is.EqualTo(p.Color))"); | ||
523 | Assert.That(text,Is.EqualTo(p.Text), "Assert.That(text,Is.EqualTo(p.Text))"); | ||
524 | Assert.That(sitname,Is.EqualTo(p.SitName), "Assert.That(sitname,Is.EqualTo(p.SitName))"); | ||
525 | Assert.That(touchname,Is.EqualTo(p.TouchName), "Assert.That(touchname,Is.EqualTo(p.TouchName))"); | ||
526 | Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); | ||
527 | Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); | ||
528 | } | ||
529 | |||
530 | /// <summary> | ||
531 | /// Test storage and retrieval of a scene object with a large number of parts. | ||
532 | /// </summary> | ||
533 | [Test] | ||
534 | public void T015_LargeSceneObjects() | ||
535 | { | ||
536 | TestHelpers.InMethod(); | ||
537 | |||
538 | UUID id = UUID.Random(); | ||
539 | Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>(); | ||
540 | SceneObjectGroup sog = NewSOG("Test SOG", id, region4); | ||
541 | mydic.Add(sog.RootPart.UUID,sog.RootPart); | ||
542 | for (int i = 0; i < 30; i++) | ||
543 | { | ||
544 | UUID tmp = UUID.Random(); | ||
545 | SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp); | ||
546 | Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next()); | ||
547 | Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next()); | ||
548 | Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next()); | ||
549 | Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next()); | ||
550 | Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next()); | ||
551 | Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next()); | ||
552 | |||
553 | sop.GroupPosition = groupos; | ||
554 | sop.RotationOffset = rotoff; | ||
555 | sop.OffsetPosition = offset; | ||
556 | sop.Velocity = velocity; | ||
557 | sop.AngularVelocity = angvelo; | ||
558 | sop.Acceleration = accel; | ||
559 | |||
560 | mydic.Add(tmp,sop); | ||
561 | sog.AddPart(sop); | ||
562 | } | ||
563 | |||
564 | db.StoreObject(sog, region4); | ||
565 | |||
566 | SceneObjectGroup retsog = FindSOG("Test SOG", region4); | ||
567 | SceneObjectPart[] parts = retsog.Parts; | ||
568 | for (int i = 0; i < 30; i++) | ||
569 | { | ||
570 | SceneObjectPart cursop = mydic[parts[i].UUID]; | ||
571 | Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition), "Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition))"); | ||
572 | Assert.That(cursop.RotationOffset,Is.EqualTo(parts[i].RotationOffset), "Assert.That(cursop.RotationOffset,Is.EqualTo(parts[i].RotationOffset))"); | ||
573 | Assert.That(cursop.OffsetPosition,Is.EqualTo(parts[i].OffsetPosition), "Assert.That(cursop.OffsetPosition,Is.EqualTo(parts[i].OffsetPosition))"); | ||
574 | Assert.That(cursop.Velocity,Is.EqualTo(parts[i].Velocity), "Assert.That(cursop.Velocity,Is.EqualTo(parts[i].Velocity))"); | ||
575 | Assert.That(cursop.AngularVelocity,Is.EqualTo(parts[i].AngularVelocity), "Assert.That(cursop.AngularVelocity,Is.EqualTo(parts[i].AngularVelocity))"); | ||
576 | Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration), "Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration))"); | ||
577 | } | ||
578 | } | ||
579 | |||
580 | //[Test] | ||
581 | public void T016_RandomSogWithSceneParts() | ||
582 | { | ||
583 | TestHelpers.InMethod(); | ||
584 | |||
585 | PropertyScrambler<SceneObjectPart> scrambler = | ||
586 | new PropertyScrambler<SceneObjectPart>() | ||
587 | .DontScramble(x => x.UUID); | ||
588 | UUID tmpSog = UUID.Random(); | ||
589 | UUID tmp1 = UUID.Random(); | ||
590 | UUID tmp2 = UUID.Random(); | ||
591 | UUID tmp3 = UUID.Random(); | ||
592 | UUID newregion = UUID.Random(); | ||
593 | SceneObjectPart p1 = new SceneObjectPart(); | ||
594 | SceneObjectPart p2 = new SceneObjectPart(); | ||
595 | SceneObjectPart p3 = new SceneObjectPart(); | ||
596 | p1.Shape = PrimitiveBaseShape.Default; | ||
597 | p2.Shape = PrimitiveBaseShape.Default; | ||
598 | p3.Shape = PrimitiveBaseShape.Default; | ||
599 | p1.UUID = tmp1; | ||
600 | p2.UUID = tmp2; | ||
601 | p3.UUID = tmp3; | ||
602 | scrambler.Scramble(p1); | ||
603 | scrambler.Scramble(p2); | ||
604 | scrambler.Scramble(p3); | ||
605 | |||
606 | SceneObjectGroup sog = NewSOG("Sop 0", tmpSog, newregion); | ||
607 | PropertyScrambler<SceneObjectGroup> sogScrambler = | ||
608 | new PropertyScrambler<SceneObjectGroup>() | ||
609 | .DontScramble(x => x.UUID); | ||
610 | sogScrambler.Scramble(sog); | ||
611 | sog.UUID = tmpSog; | ||
612 | sog.AddPart(p1); | ||
613 | sog.AddPart(p2); | ||
614 | sog.AddPart(p3); | ||
615 | |||
616 | SceneObjectPart[] parts = sog.Parts; | ||
617 | Assert.That(parts.Length, Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))"); | ||
618 | |||
619 | db.StoreObject(sog, newregion); | ||
620 | List<SceneObjectGroup> sogs = db.LoadObjects(newregion); | ||
621 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))"); | ||
622 | SceneObjectGroup newsog = sogs[0]; | ||
623 | |||
624 | SceneObjectPart[] newparts = newsog.Parts; | ||
625 | Assert.That(newparts.Length, Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))"); | ||
626 | |||
627 | Assert.That(newsog, Constraints.PropertyCompareConstraint(sog) | ||
628 | .IgnoreProperty(x=>x.LocalId) | ||
629 | .IgnoreProperty(x=>x.HasGroupChanged) | ||
630 | .IgnoreProperty(x=>x.IsSelected) | ||
631 | .IgnoreProperty(x=>x.RegionHandle) | ||
632 | .IgnoreProperty(x=>x.RegionUUID) | ||
633 | .IgnoreProperty(x=>x.Scene) | ||
634 | .IgnoreProperty(x=>x.Parts) | ||
635 | .IgnoreProperty(x=>x.PassCollision) | ||
636 | .IgnoreProperty(x=>x.RootPart)); | ||
637 | } | ||
638 | |||
639 | |||
640 | private SceneObjectGroup GetMySOG(string name) | ||
641 | { | ||
642 | SceneObjectGroup sog = FindSOG(name, region1); | ||
643 | if (sog == null) | ||
644 | { | ||
645 | sog = NewSOG(name, prim1, region1); | ||
646 | db.StoreObject(sog, region1); | ||
647 | } | ||
648 | return sog; | ||
649 | } | ||
650 | |||
651 | // NOTE: it is a bad practice to rely on some of the previous tests having been run before. | ||
652 | // If the tests are run manually, one at a time, each starts with full class init (DB cleared). | ||
653 | // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order. | ||
654 | // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*! | ||
655 | |||
656 | [Test] | ||
657 | public void T020_PrimInventoryEmpty() | ||
658 | { | ||
659 | TestHelpers.InMethod(); | ||
660 | |||
661 | SceneObjectGroup sog = GetMySOG("object1"); | ||
662 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | ||
663 | Assert.That(t, Is.Null); | ||
664 | } | ||
665 | |||
666 | // TODO: Is there any point to call StorePrimInventory on a list, rather than on the prim itself? | ||
667 | |||
668 | private void StoreInventory(SceneObjectGroup sog) | ||
669 | { | ||
670 | List<TaskInventoryItem> list = new List<TaskInventoryItem>(); | ||
671 | // TODO: seriously??? this is the way we need to loop to get this? | ||
672 | foreach (UUID uuid in sog.RootPart.Inventory.GetInventoryList()) | ||
673 | { | ||
674 | list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid)); | ||
675 | } | ||
676 | |||
677 | db.StorePrimInventory(sog.RootPart.UUID, list); | ||
678 | } | ||
679 | |||
680 | [Test] | ||
681 | public void T021_PrimInventoryBasic() | ||
682 | { | ||
683 | TestHelpers.InMethod(); | ||
684 | |||
685 | SceneObjectGroup sog = GetMySOG("object1"); | ||
686 | InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero); | ||
687 | |||
688 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); | ||
689 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | ||
690 | Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); | ||
691 | |||
692 | StoreInventory(sog); | ||
693 | |||
694 | SceneObjectGroup sog1 = FindSOG("object1", region1); | ||
695 | Assert.That(sog1, Is.Not.Null); | ||
696 | |||
697 | TaskInventoryItem t1 = sog1.GetInventoryItem(sog1.RootPart.LocalId, item1); | ||
698 | Assert.That(t1, Is.Not.Null); | ||
699 | Assert.That(t1.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); | ||
700 | |||
701 | // Updating inventory | ||
702 | t1.Name = "My New Name"; | ||
703 | sog1.UpdateInventoryItem(t1); | ||
704 | |||
705 | StoreInventory(sog1); | ||
706 | |||
707 | SceneObjectGroup sog2 = FindSOG("object1", region1); | ||
708 | TaskInventoryItem t2 = sog2.GetInventoryItem(sog2.RootPart.LocalId, item1); | ||
709 | Assert.That(t2.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))"); | ||
710 | |||
711 | // Removing inventory | ||
712 | List<TaskInventoryItem> list = new List<TaskInventoryItem>(); | ||
713 | db.StorePrimInventory(prim1, list); | ||
714 | |||
715 | sog = FindSOG("object1", region1); | ||
716 | t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | ||
717 | Assert.That(t, Is.Null); | ||
718 | } | ||
719 | |||
720 | [Test] | ||
721 | public void T025_PrimInventoryPersistency() | ||
722 | { | ||
723 | TestHelpers.InMethod(); | ||
724 | |||
725 | InventoryItemBase i = new InventoryItemBase(); | ||
726 | UUID id = UUID.Random(); | ||
727 | i.ID = id; | ||
728 | UUID folder = UUID.Random(); | ||
729 | i.Folder = folder; | ||
730 | UUID owner = UUID.Random(); | ||
731 | i.Owner = owner; | ||
732 | UUID creator = UUID.Random(); | ||
733 | i.CreatorId = creator.ToString(); | ||
734 | string name = RandomName(); | ||
735 | i.Name = name; | ||
736 | i.Description = name; | ||
737 | UUID assetid = UUID.Random(); | ||
738 | i.AssetID = assetid; | ||
739 | int invtype = random.Next(); | ||
740 | i.InvType = invtype; | ||
741 | uint nextperm = (uint) random.Next(); | ||
742 | i.NextPermissions = nextperm; | ||
743 | uint curperm = (uint) random.Next(); | ||
744 | i.CurrentPermissions = curperm; | ||
745 | uint baseperm = (uint) random.Next(); | ||
746 | i.BasePermissions = baseperm; | ||
747 | uint eoperm = (uint) random.Next(); | ||
748 | i.EveryOnePermissions = eoperm; | ||
749 | int assettype = random.Next(); | ||
750 | i.AssetType = assettype; | ||
751 | UUID groupid = UUID.Random(); | ||
752 | i.GroupID = groupid; | ||
753 | bool groupown = true; | ||
754 | i.GroupOwned = groupown; | ||
755 | int saleprice = random.Next(); | ||
756 | i.SalePrice = saleprice; | ||
757 | byte saletype = (byte) random.Next(127); | ||
758 | i.SaleType = saletype; | ||
759 | uint flags = (uint) random.Next(); | ||
760 | i.Flags = flags; | ||
761 | int creationd = random.Next(); | ||
762 | i.CreationDate = creationd; | ||
763 | |||
764 | SceneObjectGroup sog = GetMySOG("object1"); | ||
765 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); | ||
766 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id); | ||
767 | |||
768 | Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))"); | ||
769 | Assert.That(t.AssetID,Is.EqualTo(assetid), "Assert.That(t.AssetID,Is.EqualTo(assetid))"); | ||
770 | Assert.That(t.BasePermissions,Is.EqualTo(baseperm), "Assert.That(t.BasePermissions,Is.EqualTo(baseperm))"); | ||
771 | Assert.That(t.CreationDate,Is.EqualTo(creationd), "Assert.That(t.CreationDate,Is.EqualTo(creationd))"); | ||
772 | Assert.That(t.CreatorID,Is.EqualTo(creator), "Assert.That(t.CreatorID,Is.EqualTo(creator))"); | ||
773 | Assert.That(t.Description,Is.EqualTo(name), "Assert.That(t.Description,Is.EqualTo(name))"); | ||
774 | Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm), "Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm))"); | ||
775 | Assert.That(t.Flags,Is.EqualTo(flags), "Assert.That(t.Flags,Is.EqualTo(flags))"); | ||
776 | Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID), "Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID))"); | ||
777 | // Where is this group permissions?? | ||
778 | // Assert.That(t.GroupPermissions,Is.EqualTo(), "Assert.That(t.GroupPermissions,Is.EqualTo())"); | ||
779 | Assert.That(t.Type,Is.EqualTo(assettype), "Assert.That(t.Type,Is.EqualTo(assettype))"); | ||
780 | Assert.That(t.InvType, Is.EqualTo(invtype), "Assert.That(t.InvType, Is.EqualTo(invtype))"); | ||
781 | Assert.That(t.ItemID, Is.EqualTo(id), "Assert.That(t.ItemID, Is.EqualTo(id))"); | ||
782 | Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID), "Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID))"); | ||
783 | Assert.That(t.NextPermissions, Is.EqualTo(nextperm), "Assert.That(t.NextPermissions, Is.EqualTo(nextperm))"); | ||
784 | // Ownership changes when you drop an object into an object | ||
785 | // owned by someone else | ||
786 | Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID), "Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID))"); | ||
787 | // Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 16), "Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8))"); | ||
788 | Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID), "Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))"); | ||
789 | Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID), "Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))"); | ||
790 | } | ||
791 | |||
792 | [Test] | ||
793 | [ExpectedException(typeof(ArgumentException))] | ||
794 | public void T026_PrimInventoryMany() | ||
795 | { | ||
796 | TestHelpers.InMethod(); | ||
797 | |||
798 | UUID i1,i2,i3,i4; | ||
799 | i1 = UUID.Random(); | ||
800 | i2 = UUID.Random(); | ||
801 | i3 = UUID.Random(); | ||
802 | i4 = i3; | ||
803 | InventoryItemBase ib1 = NewItem(i1, zero, zero, RandomName(), zero); | ||
804 | InventoryItemBase ib2 = NewItem(i2, zero, zero, RandomName(), zero); | ||
805 | InventoryItemBase ib3 = NewItem(i3, zero, zero, RandomName(), zero); | ||
806 | InventoryItemBase ib4 = NewItem(i4, zero, zero, RandomName(), zero); | ||
807 | |||
808 | SceneObjectGroup sog = FindSOG("object1", region1); | ||
809 | |||
810 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib1, zero), Is.True); | ||
811 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib2, zero), Is.True); | ||
812 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib3, zero), Is.True); | ||
813 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib4, zero), Is.True); | ||
814 | |||
815 | TaskInventoryItem t1 = sog.GetInventoryItem(sog.RootPart.LocalId, i1); | ||
816 | Assert.That(t1.Name, Is.EqualTo(ib1.Name), "Assert.That(t1.Name, Is.EqualTo(ib1.Name))"); | ||
817 | TaskInventoryItem t2 = sog.GetInventoryItem(sog.RootPart.LocalId, i2); | ||
818 | Assert.That(t2.Name, Is.EqualTo(ib2.Name), "Assert.That(t2.Name, Is.EqualTo(ib2.Name))"); | ||
819 | TaskInventoryItem t3 = sog.GetInventoryItem(sog.RootPart.LocalId, i3); | ||
820 | Assert.That(t3.Name, Is.EqualTo(ib3.Name), "Assert.That(t3.Name, Is.EqualTo(ib3.Name))"); | ||
821 | TaskInventoryItem t4 = sog.GetInventoryItem(sog.RootPart.LocalId, i4); | ||
822 | Assert.That(t4, Is.Null); | ||
823 | } | ||
824 | |||
825 | [Test] | ||
826 | public void T052_RemoveObject() | ||
827 | { | ||
828 | TestHelpers.InMethod(); | ||
829 | |||
830 | db.RemoveObject(prim1, region1); | ||
831 | SceneObjectGroup sog = FindSOG("object1", region1); | ||
832 | Assert.That(sog, Is.Null); | ||
833 | } | ||
834 | |||
835 | [Test] | ||
836 | public void T100_DefaultRegionInfo() | ||
837 | { | ||
838 | TestHelpers.InMethod(); | ||
839 | |||
840 | RegionSettings r1 = db.LoadRegionSettings(region1); | ||
841 | Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))"); | ||
842 | |||
843 | RegionSettings r2 = db.LoadRegionSettings(region2); | ||
844 | Assert.That(r2.RegionUUID, Is.EqualTo(region2), "Assert.That(r2.RegionUUID, Is.EqualTo(region2))"); | ||
845 | } | ||
846 | |||
847 | [Test] | ||
848 | public void T101_UpdateRegionInfo() | ||
849 | { | ||
850 | TestHelpers.InMethod(); | ||
851 | |||
852 | int agentlimit = random.Next(); | ||
853 | double objectbonus = random.Next(); | ||
854 | int maturity = random.Next(); | ||
855 | UUID tertex1 = UUID.Random(); | ||
856 | UUID tertex2 = UUID.Random(); | ||
857 | UUID tertex3 = UUID.Random(); | ||
858 | UUID tertex4 = UUID.Random(); | ||
859 | double elev1nw = random.Next(); | ||
860 | double elev2nw = random.Next(); | ||
861 | double elev1ne = random.Next(); | ||
862 | double elev2ne = random.Next(); | ||
863 | double elev1se = random.Next(); | ||
864 | double elev2se = random.Next(); | ||
865 | double elev1sw = random.Next(); | ||
866 | double elev2sw = random.Next(); | ||
867 | double waterh = random.Next(); | ||
868 | double terrainraise = random.Next(); | ||
869 | double terrainlower = random.Next(); | ||
870 | Vector3 sunvector = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5)); | ||
871 | UUID terimgid = UUID.Random(); | ||
872 | double sunpos = random.Next(); | ||
873 | UUID cov = UUID.Random(); | ||
874 | |||
875 | RegionSettings r1 = db.LoadRegionSettings(region1); | ||
876 | r1.BlockTerraform = true; | ||
877 | r1.BlockFly = true; | ||
878 | r1.AllowDamage = true; | ||
879 | r1.RestrictPushing = true; | ||
880 | r1.AllowLandResell = false; | ||
881 | r1.AllowLandJoinDivide = false; | ||
882 | r1.BlockShowInSearch = true; | ||
883 | r1.AgentLimit = agentlimit; | ||
884 | r1.ObjectBonus = objectbonus; | ||
885 | r1.Maturity = maturity; | ||
886 | r1.DisableScripts = true; | ||
887 | r1.DisableCollisions = true; | ||
888 | r1.DisablePhysics = true; | ||
889 | r1.TerrainTexture1 = tertex1; | ||
890 | r1.TerrainTexture2 = tertex2; | ||
891 | r1.TerrainTexture3 = tertex3; | ||
892 | r1.TerrainTexture4 = tertex4; | ||
893 | r1.Elevation1NW = elev1nw; | ||
894 | r1.Elevation2NW = elev2nw; | ||
895 | r1.Elevation1NE = elev1ne; | ||
896 | r1.Elevation2NE = elev2ne; | ||
897 | r1.Elevation1SE = elev1se; | ||
898 | r1.Elevation2SE = elev2se; | ||
899 | r1.Elevation1SW = elev1sw; | ||
900 | r1.Elevation2SW = elev2sw; | ||
901 | r1.WaterHeight = waterh; | ||
902 | r1.TerrainRaiseLimit = terrainraise; | ||
903 | r1.TerrainLowerLimit = terrainlower; | ||
904 | r1.UseEstateSun = false; | ||
905 | r1.Sandbox = true; | ||
906 | r1.SunVector = sunvector; | ||
907 | r1.TerrainImageID = terimgid; | ||
908 | r1.FixedSun = true; | ||
909 | r1.SunPosition = sunpos; | ||
910 | r1.Covenant = cov; | ||
911 | |||
912 | db.StoreRegionSettings(r1); | ||
913 | |||
914 | RegionSettings r1a = db.LoadRegionSettings(region1); | ||
915 | Assert.That(r1a.RegionUUID, Is.EqualTo(region1), "Assert.That(r1a.RegionUUID, Is.EqualTo(region1))"); | ||
916 | Assert.That(r1a.BlockTerraform,Is.True); | ||
917 | Assert.That(r1a.BlockFly,Is.True); | ||
918 | Assert.That(r1a.AllowDamage,Is.True); | ||
919 | Assert.That(r1a.RestrictPushing,Is.True); | ||
920 | Assert.That(r1a.AllowLandResell,Is.False); | ||
921 | Assert.That(r1a.AllowLandJoinDivide,Is.False); | ||
922 | Assert.That(r1a.BlockShowInSearch,Is.True); | ||
923 | Assert.That(r1a.AgentLimit,Is.EqualTo(agentlimit), "Assert.That(r1a.AgentLimit,Is.EqualTo(agentlimit))"); | ||
924 | Assert.That(r1a.ObjectBonus,Is.EqualTo(objectbonus), "Assert.That(r1a.ObjectBonus,Is.EqualTo(objectbonus))"); | ||
925 | Assert.That(r1a.Maturity,Is.EqualTo(maturity), "Assert.That(r1a.Maturity,Is.EqualTo(maturity))"); | ||
926 | Assert.That(r1a.DisableScripts,Is.True); | ||
927 | Assert.That(r1a.DisableCollisions,Is.True); | ||
928 | Assert.That(r1a.DisablePhysics,Is.True); | ||
929 | Assert.That(r1a.TerrainTexture1,Is.EqualTo(tertex1), "Assert.That(r1a.TerrainTexture1,Is.EqualTo(tertex1))"); | ||
930 | Assert.That(r1a.TerrainTexture2,Is.EqualTo(tertex2), "Assert.That(r1a.TerrainTexture2,Is.EqualTo(tertex2))"); | ||
931 | Assert.That(r1a.TerrainTexture3,Is.EqualTo(tertex3), "Assert.That(r1a.TerrainTexture3,Is.EqualTo(tertex3))"); | ||
932 | Assert.That(r1a.TerrainTexture4,Is.EqualTo(tertex4), "Assert.That(r1a.TerrainTexture4,Is.EqualTo(tertex4))"); | ||
933 | Assert.That(r1a.Elevation1NW,Is.EqualTo(elev1nw), "Assert.That(r1a.Elevation1NW,Is.EqualTo(elev1nw))"); | ||
934 | Assert.That(r1a.Elevation2NW,Is.EqualTo(elev2nw), "Assert.That(r1a.Elevation2NW,Is.EqualTo(elev2nw))"); | ||
935 | Assert.That(r1a.Elevation1NE,Is.EqualTo(elev1ne), "Assert.That(r1a.Elevation1NE,Is.EqualTo(elev1ne))"); | ||
936 | Assert.That(r1a.Elevation2NE,Is.EqualTo(elev2ne), "Assert.That(r1a.Elevation2NE,Is.EqualTo(elev2ne))"); | ||
937 | Assert.That(r1a.Elevation1SE,Is.EqualTo(elev1se), "Assert.That(r1a.Elevation1SE,Is.EqualTo(elev1se))"); | ||
938 | Assert.That(r1a.Elevation2SE,Is.EqualTo(elev2se), "Assert.That(r1a.Elevation2SE,Is.EqualTo(elev2se))"); | ||
939 | Assert.That(r1a.Elevation1SW,Is.EqualTo(elev1sw), "Assert.That(r1a.Elevation1SW,Is.EqualTo(elev1sw))"); | ||
940 | Assert.That(r1a.Elevation2SW,Is.EqualTo(elev2sw), "Assert.That(r1a.Elevation2SW,Is.EqualTo(elev2sw))"); | ||
941 | Assert.That(r1a.WaterHeight,Is.EqualTo(waterh), "Assert.That(r1a.WaterHeight,Is.EqualTo(waterh))"); | ||
942 | Assert.That(r1a.TerrainRaiseLimit,Is.EqualTo(terrainraise), "Assert.That(r1a.TerrainRaiseLimit,Is.EqualTo(terrainraise))"); | ||
943 | Assert.That(r1a.TerrainLowerLimit,Is.EqualTo(terrainlower), "Assert.That(r1a.TerrainLowerLimit,Is.EqualTo(terrainlower))"); | ||
944 | Assert.That(r1a.UseEstateSun,Is.False); | ||
945 | Assert.That(r1a.Sandbox,Is.True); | ||
946 | Assert.That(r1a.SunVector,Is.EqualTo(sunvector), "Assert.That(r1a.SunVector,Is.EqualTo(sunvector))"); | ||
947 | //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))"); | ||
948 | Assert.That(r1a.FixedSun,Is.True); | ||
949 | Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))"); | ||
950 | Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))"); | ||
951 | } | ||
952 | |||
953 | [Test] | ||
954 | public void T300_NoTerrain() | ||
955 | { | ||
956 | TestHelpers.InMethod(); | ||
957 | |||
958 | Assert.That(db.LoadTerrain(zero), Is.Null); | ||
959 | Assert.That(db.LoadTerrain(region1), Is.Null); | ||
960 | Assert.That(db.LoadTerrain(region2), Is.Null); | ||
961 | Assert.That(db.LoadTerrain(UUID.Random()), Is.Null); | ||
962 | } | ||
963 | |||
964 | [Test] | ||
965 | public void T301_CreateTerrain() | ||
966 | { | ||
967 | TestHelpers.InMethod(); | ||
968 | |||
969 | double[,] t1 = GenTerrain(height1); | ||
970 | db.StoreTerrain(t1, region1); | ||
971 | |||
972 | Assert.That(db.LoadTerrain(zero), Is.Null); | ||
973 | Assert.That(db.LoadTerrain(region1), Is.Not.Null); | ||
974 | Assert.That(db.LoadTerrain(region2), Is.Null); | ||
975 | Assert.That(db.LoadTerrain(UUID.Random()), Is.Null); | ||
976 | } | ||
977 | |||
978 | [Test] | ||
979 | public void T302_FetchTerrain() | ||
980 | { | ||
981 | TestHelpers.InMethod(); | ||
982 | |||
983 | double[,] baseterrain1 = GenTerrain(height1); | ||
984 | double[,] baseterrain2 = GenTerrain(height2); | ||
985 | double[,] t1 = db.LoadTerrain(region1); | ||
986 | Assert.That(CompareTerrain(t1, baseterrain1), Is.True); | ||
987 | Assert.That(CompareTerrain(t1, baseterrain2), Is.False); | ||
988 | } | ||
989 | |||
990 | [Test] | ||
991 | public void T303_UpdateTerrain() | ||
992 | { | ||
993 | TestHelpers.InMethod(); | ||
994 | |||
995 | double[,] baseterrain1 = GenTerrain(height1); | ||
996 | double[,] baseterrain2 = GenTerrain(height2); | ||
997 | db.StoreTerrain(baseterrain2, region1); | ||
998 | |||
999 | double[,] t1 = db.LoadTerrain(region1); | ||
1000 | Assert.That(CompareTerrain(t1, baseterrain1), Is.False); | ||
1001 | Assert.That(CompareTerrain(t1, baseterrain2), Is.True); | ||
1002 | } | ||
1003 | |||
1004 | [Test] | ||
1005 | public void T400_EmptyLand() | ||
1006 | { | ||
1007 | TestHelpers.InMethod(); | ||
1008 | |||
1009 | Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))"); | ||
1010 | Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))"); | ||
1011 | Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))"); | ||
1012 | Assert.That(db.LoadLandObjects(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(UUID.Random()).Count, Is.EqualTo(0))"); | ||
1013 | } | ||
1014 | |||
1015 | // TODO: we should have real land tests, but Land is so | ||
1016 | // intermingled with scene that you can't test it without a | ||
1017 | // valid scene. That requires some disagregation. | ||
1018 | |||
1019 | |||
1020 | //************************************************************************************// | ||
1021 | // Extra private methods | ||
1022 | |||
1023 | private double[,] GenTerrain(double value) | ||
1024 | { | ||
1025 | double[,] terret = new double[Constants.RegionSize, Constants.RegionSize]; | ||
1026 | terret.Initialize(); | ||
1027 | for (int x = 0; x < Constants.RegionSize; x++) | ||
1028 | for (int y = 0; y < Constants.RegionSize; y++) | ||
1029 | terret[x,y] = value; | ||
1030 | |||
1031 | return terret; | ||
1032 | } | ||
1033 | |||
1034 | private bool CompareTerrain(double[,] one, double[,] two) | ||
1035 | { | ||
1036 | for (int x = 0; x < Constants.RegionSize; x++) | ||
1037 | for (int y = 0; y < Constants.RegionSize; y++) | ||
1038 | if (one[x,y] != two[x,y]) | ||
1039 | return false; | ||
1040 | |||
1041 | return true; | ||
1042 | } | ||
1043 | |||
1044 | private SceneObjectGroup FindSOG(string name, UUID r) | ||
1045 | { | ||
1046 | List<SceneObjectGroup> objs = db.LoadObjects(r); | ||
1047 | foreach (SceneObjectGroup sog in objs) | ||
1048 | if (sog.Name == name) | ||
1049 | return sog; | ||
1050 | |||
1051 | return null; | ||
1052 | } | ||
1053 | |||
1054 | // This builds a minimalistic Prim, 1 SOG with 1 root SOP. A | ||
1055 | // common failure case is people adding new fields that aren't | ||
1056 | // initialized, but have non-null db constraints. We should | ||
1057 | // honestly be passing more and more null things in here. | ||
1058 | // | ||
1059 | // Please note that in Sqlite.BuildPrim there is a commented out inline version | ||
1060 | // of this so you can debug and step through the build process and check the fields | ||
1061 | // | ||
1062 | // Real World Value: Tests for situation where extending a SceneObjectGroup/SceneObjectPart | ||
1063 | // causes the application to crash at the database layer because of null values | ||
1064 | // in NOT NULL fields | ||
1065 | // | ||
1066 | private SceneObjectGroup NewSOG(string name, UUID uuid, UUID regionId) | ||
1067 | { | ||
1068 | RegionInfo regionInfo = new RegionInfo(); | ||
1069 | regionInfo.RegionID = regionId; | ||
1070 | regionInfo.RegionLocX = 0; | ||
1071 | regionInfo.RegionLocY = 0; | ||
1072 | |||
1073 | Scene scene = new Scene(regionInfo); | ||
1074 | |||
1075 | SceneObjectPart sop = new SceneObjectPart(); | ||
1076 | sop.Name = name; | ||
1077 | sop.Description = name; | ||
1078 | sop.Text = RandomName(); | ||
1079 | sop.SitName = RandomName(); | ||
1080 | sop.TouchName = RandomName(); | ||
1081 | sop.UUID = uuid; | ||
1082 | sop.Shape = PrimitiveBaseShape.Default; | ||
1083 | |||
1084 | SceneObjectGroup sog = new SceneObjectGroup(sop); | ||
1085 | sog.SetScene(scene); | ||
1086 | |||
1087 | return sog; | ||
1088 | } | ||
1089 | |||
1090 | private SceneObjectPart NewSOP(string name, UUID uuid) | ||
1091 | { | ||
1092 | SceneObjectPart sop = new SceneObjectPart(); | ||
1093 | sop.Name = name; | ||
1094 | sop.Description = name; | ||
1095 | sop.Text = RandomName(); | ||
1096 | sop.SitName = RandomName(); | ||
1097 | sop.TouchName = RandomName(); | ||
1098 | sop.UUID = uuid; | ||
1099 | sop.Shape = PrimitiveBaseShape.Default; | ||
1100 | return sop; | ||
1101 | } | ||
1102 | |||
1103 | // These are copied from the Inventory Item tests | ||
1104 | |||
1105 | private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset) | ||
1106 | { | ||
1107 | InventoryItemBase i = new InventoryItemBase(); | ||
1108 | i.ID = id; | ||
1109 | i.Folder = parent; | ||
1110 | i.Owner = owner; | ||
1111 | i.CreatorId = owner.ToString(); | ||
1112 | i.Name = name; | ||
1113 | i.Description = name; | ||
1114 | i.AssetID = asset; | ||
1115 | return i; | ||
1116 | } | ||
1117 | |||
1118 | private static string RandomName() | ||
1119 | { | ||
1120 | StringBuilder name = new StringBuilder(); | ||
1121 | int size = random.Next(5,12); | ||
1122 | char ch ; | ||
1123 | for (int i=0; i<size; i++) | ||
1124 | { | ||
1125 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
1126 | name.Append(ch); | ||
1127 | } | ||
1128 | return name.ToString(); | ||
1129 | } | ||
1130 | // private InventoryFolderBase NewFolder(UUID id, UUID parent, UUID owner, string name) | ||
1131 | // { | ||
1132 | // InventoryFolderBase f = new InventoryFolderBase(); | ||
1133 | // f.ID = id; | ||
1134 | // f.ParentID = parent; | ||
1135 | // f.Owner = owner; | ||
1136 | // f.Name = name; | ||
1137 | // return f; | ||
1138 | // } | ||
1139 | } | ||
1140 | } | ||