29 using System.Collections.Generic;
33 using NUnit.Framework;
35 using OpenSim.Framework;
36 using OpenSim.Region.Framework.Interfaces;
37 using OpenSim.Region.Framework.Scenes;
38 using OpenSim.Tests.Common;
40 using System.Reflection;
41 using System.Data.Common;
42 using System.Threading;
45 using MySql.Data.MySqlClient;
46 using OpenSim.Data.MySQL;
48 using Mono.Data.Sqlite;
49 using OpenSim.Data.SQLite;
51 namespace OpenSim.Data.Tests
53 [TestFixture(Description =
"Region store tests (SQLite)")]
58 [TestFixture(Description =
"Region store tests (MySQL)")]
63 public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore>
64 where TConn : DbConnection, new()
70 public UUID zero = UUID.Zero;
71 public UUID region1 = UUID.Random();
72 public UUID region2 = UUID.Random();
73 public UUID region3 = UUID.Random();
74 public UUID region4 = UUID.Random();
75 public UUID prim1 = UUID.Random();
76 public UUID prim2 = UUID.Random();
77 public UUID prim3 = UUID.Random();
78 public UUID prim4 = UUID.Random();
79 public UUID prim5 = UUID.Random();
80 public UUID prim6 = UUID.Random();
81 public UUID item1 = UUID.Random();
82 public UUID item2 = UUID.Random();
83 public UUID item3 = UUID.Random();
85 public static Random random =
new Random();
87 public string itemname1 =
"item1";
89 public uint localID = 1;
91 public double height1 = 20;
92 public double height2 = 100;
97 m_rebuildDB = rebuild;
109 db.Initialise(m_connStr);
112 private void ClearDB()
114 string[] reg_tables =
new string[] {
115 "prims",
"primshapes",
"primitems",
"terrain",
"land",
"landaccesslist",
"regionban",
"regionsettings"
120 DropTables(reg_tables);
121 ResetMigrations(
"RegionStore");
125 ClearTables(reg_tables);
147 TestHelpers.InMethod();
149 List<SceneObjectGroup> objs = db.LoadObjects(region1);
150 List<SceneObjectGroup> objs3 = db.LoadObjects(region3);
151 List<LandData> land = db.LoadLandObjects(region1);
153 Assert.That(objs.Count, Is.EqualTo(0),
"Assert.That(objs.Count, Is.EqualTo(0))");
154 Assert.That(objs3.Count, Is.EqualTo(0),
"Assert.That(objs3.Count, Is.EqualTo(0))");
155 Assert.That(land.Count, Is.EqualTo(0),
"Assert.That(land.Count, Is.EqualTo(0))");
165 TestHelpers.InMethod();
173 db.StoreObject(sog, region1);
177 m_log.Error(e.ToString());
183 db.StoreObject(sog2, region1);
187 m_log.Error(e.ToString());
192 List<SceneObjectGroup> objs = db.LoadObjects(region1);
194 Assert.That(objs.Count, Is.EqualTo(2),
"Assert.That(objs.Count, Is.EqualTo(2))");
200 TestHelpers.InMethod();
202 List<SceneObjectGroup> objs = db.LoadObjects(region1);
206 Assert.That(
"", Is.Not.EqualTo(p.Name),
"Assert.That(\"\", Is.Not.EqualTo(p.Name))");
207 Assert.That(p.Name, Is.EqualTo(p.Description),
"Assert.That(p.Name, Is.EqualTo(p.Description))");
214 TestHelpers.InMethod();
216 UUID tmp0 = UUID.Random();
217 UUID tmp1 = UUID.Random();
218 UUID tmp2 = UUID.Random();
219 UUID tmp3 = UUID.Random();
220 UUID newregion = UUID.Random();
230 Assert.That(parts.Length,Is.EqualTo(4),
"Assert.That(parts.Length,Is.EqualTo(4))");
232 db.StoreObject(sog, newregion);
233 List<SceneObjectGroup> sogs = db.LoadObjects(newregion);
234 Assert.That(sogs.Count,Is.EqualTo(1),
"Assert.That(sogs.Count,Is.EqualTo(1))");
238 Assert.That(newparts.Length,Is.EqualTo(4),
"Assert.That(newparts.Length,Is.EqualTo(4))");
240 Assert.That(newsog.ContainsPart(tmp0),
"Assert.That(newsog.ContainsPart(tmp0))");
241 Assert.That(newsog.ContainsPart(tmp1),
"Assert.That(newsog.ContainsPart(tmp1))");
242 Assert.That(newsog.ContainsPart(tmp2),
"Assert.That(newsog.ContainsPart(tmp2))");
243 Assert.That(newsog.ContainsPart(tmp3),
"Assert.That(newsog.ContainsPart(tmp3))");
249 TestHelpers.InMethod();
255 creator = UUID.Random();
256 uint iserial = (uint)random.Next();
258 uint objf = (uint) random.Next();
260 uint localid = localID+1;
261 localID = localID + 1;
262 string name =
"Adam West";
263 byte material = (byte) random.Next((
int)SOPMaterialData.MaxMaterial);
264 ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next();
265 int pin = random.Next();
266 Byte[] partsys =
new byte[8];
267 Byte[] textani =
new byte[8];
268 random.NextBytes(textani);
269 random.NextBytes(partsys);
270 DateTime expires =
new DateTime(2008, 12, 20);
271 DateTime rezzed =
new DateTime(2009, 07, 15);
272 Vector3 groupos =
new Vector3(random.Next(),random.Next(),random.Next());
273 Vector3 offset =
new Vector3(random.Next(),random.Next(),random.Next());
274 Quaternion rotoff =
new Quaternion(random.Next(),random.Next(),random.Next(),random.Next());
275 Vector3 velocity =
new Vector3(random.Next(),random.Next(),random.Next());
276 Vector3 angvelo =
new Vector3(random.Next(),random.Next(),random.Next());
277 Vector3 accel =
new Vector3(random.Next(),random.Next(),random.Next());
278 string description = name;
279 Color color = Color.FromArgb(255, 165, 50, 100);
280 string text =
"All Your Base Are Belong to Us";
281 string sitname =
"SitName";
282 string touchname =
"TouchName";
283 int linknum = random.Next();
284 byte clickaction = (byte) random.Next(127);
286 pbshap = PrimitiveBaseShape.Default;
287 pbshap.PathBegin = ushort.MaxValue;
288 pbshap.PathEnd = ushort.MaxValue;
289 pbshap.ProfileBegin = ushort.MaxValue;
290 pbshap.ProfileEnd = ushort.MaxValue;
291 pbshap.ProfileHollow = ushort.MaxValue;
292 Vector3 scale =
new Vector3(random.Next(),random.Next(),random.Next());
295 regionInfo.RegionID = region3;
296 regionInfo.RegionLocX = 0;
297 regionInfo.RegionLocY = 0;
302 sop.RegionHandle = regionh;
304 sop.LocalId = localid;
306 sop.GroupPosition = groupos;
307 sop.RotationOffset = rotoff;
308 sop.CreatorID = creator;
309 sop.InventorySerial = iserial;
310 sop.TaskInventory = dic;
313 sop.Material = material;
314 sop.ScriptAccessPin = pin;
315 sop.TextureAnimation = textani;
316 sop.ParticleSystem = partsys;
317 sop.Expires = expires;
319 sop.OffsetPosition = offset;
320 sop.Velocity = velocity;
321 sop.AngularVelocity = angvelo;
322 sop.Acceleration = accel;
323 sop.Description = description;
326 sop.SitName = sitname;
327 sop.TouchName = touchname;
328 sop.LinkNum = linknum;
329 sop.ClickAction = clickaction;
333 Assert.That(regionh,Is.EqualTo(sop.RegionHandle),
"Assert.That(regionh,Is.EqualTo(sop.RegionHandle))");
334 Assert.That(localid,Is.EqualTo(sop.LocalId),
"Assert.That(localid,Is.EqualTo(sop.LocalId))");
335 Assert.That(groupos,Is.EqualTo(sop.GroupPosition),
"Assert.That(groupos,Is.EqualTo(sop.GroupPosition))");
336 Assert.That(name,Is.EqualTo(sop.Name),
"Assert.That(name,Is.EqualTo(sop.Name))");
337 Assert.That(rotoff,Is.EqualTo(sop.RotationOffset),
"Assert.That(rotoff,Is.EqualTo(sop.RotationOffset))");
338 Assert.That(uuid,Is.EqualTo(sop.UUID),
"Assert.That(uuid,Is.EqualTo(sop.UUID))");
339 Assert.That(creator,Is.EqualTo(sop.CreatorID),
"Assert.That(creator,Is.EqualTo(sop.CreatorID))");
342 Assert.That(dic,Is.EqualTo(sop.TaskInventory),
"Assert.That(dic,Is.EqualTo(sop.TaskInventory))");
343 Assert.That(objf, Is.EqualTo((uint)sop.
Flags),
"Assert.That(objf,Is.EqualTo(sop.Flags))");
344 Assert.That(name,Is.EqualTo(sop.Name),
"Assert.That(name,Is.EqualTo(sop.Name))");
345 Assert.That(material,Is.EqualTo(
sop.Material),
"Assert.That(material,Is.EqualTo(sop.Material))");
346 Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin),
"Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin))");
347 Assert.That(textani,Is.EqualTo(sop.TextureAnimation),
"Assert.That(textani,Is.EqualTo(sop.TextureAnimation))");
348 Assert.That(partsys,Is.EqualTo(sop.ParticleSystem),
"Assert.That(partsys,Is.EqualTo(sop.ParticleSystem))");
349 Assert.That(expires,Is.EqualTo(sop.Expires),
"Assert.That(expires,Is.EqualTo(sop.Expires))");
350 Assert.That(rezzed,Is.EqualTo(sop.Rezzed),
"Assert.That(rezzed,Is.EqualTo(sop.Rezzed))");
351 Assert.That(offset,Is.EqualTo(sop.OffsetPosition),
"Assert.That(offset,Is.EqualTo(sop.OffsetPosition))");
352 Assert.That(velocity,Is.EqualTo(sop.Velocity),
"Assert.That(velocity,Is.EqualTo(sop.Velocity))");
353 Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity),
"Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity))");
354 Assert.That(accel,Is.EqualTo(sop.Acceleration),
"Assert.That(accel,Is.EqualTo(sop.Acceleration))");
355 Assert.That(description,Is.EqualTo(sop.Description),
"Assert.That(description,Is.EqualTo(sop.Description))");
356 Assert.That(color,Is.EqualTo(sop.Color),
"Assert.That(color,Is.EqualTo(sop.Color))");
357 Assert.That(text,Is.EqualTo(sop.Text),
"Assert.That(text,Is.EqualTo(sop.Text))");
358 Assert.That(sitname,Is.EqualTo(sop.SitName),
"Assert.That(sitname,Is.EqualTo(sop.SitName))");
359 Assert.That(touchname,Is.EqualTo(sop.TouchName),
"Assert.That(touchname,Is.EqualTo(sop.TouchName))");
360 Assert.That(linknum,Is.EqualTo(sop.LinkNum),
"Assert.That(linknum,Is.EqualTo(sop.LinkNum))");
361 Assert.That(clickaction,Is.EqualTo(sop.ClickAction),
"Assert.That(clickaction,Is.EqualTo(sop.ClickAction))");
362 Assert.That(scale,Is.EqualTo(sop.Scale),
"Assert.That(scale,Is.EqualTo(sop.Scale))");
365 sop.Flags = PrimFlags.None;
368 db.StoreObject(sog,region3);
369 List<SceneObjectGroup> sogs = db.LoadObjects(region3);
370 Assert.That(sogs.Count, Is.EqualTo(1),
"Assert.That(sogs.Count, Is.EqualTo(1))");
372 db.StoreObject(sog,region3);
373 sogs = db.LoadObjects(region3);
374 Assert.That(sogs.Count, Is.EqualTo(1),
"Assert.That(sogs.Count, Is.EqualTo(1))");
379 Assert.That(regionh,Is.EqualTo(p.RegionHandle),
"Assert.That(regionh,Is.EqualTo(p.RegionHandle))");
381 Assert.That(groupos,Is.EqualTo(p.GroupPosition),
"Assert.That(groupos,Is.EqualTo(p.GroupPosition))");
382 Assert.That(name,Is.EqualTo(p.Name),
"Assert.That(name,Is.EqualTo(p.Name))");
383 Assert.That(rotoff,Is.EqualTo(p.RotationOffset),
"Assert.That(rotoff,Is.EqualTo(p.RotationOffset))");
384 Assert.That(uuid,Is.EqualTo(p.UUID),
"Assert.That(uuid,Is.EqualTo(p.UUID))");
385 Assert.That(creator,Is.EqualTo(p.CreatorID),
"Assert.That(creator,Is.EqualTo(p.CreatorID))");
387 Assert.That(dic,Is.EqualTo(p.TaskInventory),
"Assert.That(dic,Is.EqualTo(p.TaskInventory))");
389 Assert.That(name,Is.EqualTo(p.Name),
"Assert.That(name,Is.EqualTo(p.Name))");
390 Assert.That(material,Is.EqualTo(
p.Material),
"Assert.That(material,Is.EqualTo(p.Material))");
391 Assert.That(pin,Is.EqualTo(p.ScriptAccessPin),
"Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))");
392 Assert.That(textani,Is.EqualTo(p.TextureAnimation),
"Assert.That(textani,Is.EqualTo(p.TextureAnimation))");
393 Assert.That(partsys,Is.EqualTo(p.ParticleSystem),
"Assert.That(partsys,Is.EqualTo(p.ParticleSystem))");
396 Assert.That(offset,Is.EqualTo(p.OffsetPosition),
"Assert.That(offset,Is.EqualTo(p.OffsetPosition))");
397 Assert.That(velocity,Is.EqualTo(p.Velocity),
"Assert.That(velocity,Is.EqualTo(p.Velocity))");
398 Assert.That(angvelo,Is.EqualTo(p.AngularVelocity),
"Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))");
399 Assert.That(accel,Is.EqualTo(p.Acceleration),
"Assert.That(accel,Is.EqualTo(p.Acceleration))");
400 Assert.That(description,Is.EqualTo(p.Description),
"Assert.That(description,Is.EqualTo(p.Description))");
401 Assert.That(color,Is.EqualTo(p.Color),
"Assert.That(color,Is.EqualTo(p.Color))");
402 Assert.That(text,Is.EqualTo(p.Text),
"Assert.That(text,Is.EqualTo(p.Text))");
403 Assert.That(sitname,Is.EqualTo(p.SitName),
"Assert.That(sitname,Is.EqualTo(p.SitName))");
404 Assert.That(touchname,Is.EqualTo(p.TouchName),
"Assert.That(touchname,Is.EqualTo(p.TouchName))");
406 Assert.That(clickaction,Is.EqualTo(p.ClickAction),
"Assert.That(clickaction,Is.EqualTo(p.ClickAction))");
407 Assert.That(scale,Is.EqualTo(p.Scale),
"Assert.That(scale,Is.EqualTo(p.Scale))");
411 Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin),
"Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin))");
412 Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd),
"Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd))");
413 Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin),
"Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin))");
414 Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd),
"Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd))");
415 Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow),
"Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow))");
421 TestHelpers.InMethod();
423 string text1 =
"object1 text";
425 sog.RootPart.Text = text1;
426 db.StoreObject(sog, region1);
428 sog = FindSOG(
"object1", region1);
429 Assert.That(text1, Is.EqualTo(sog.RootPart.Text),
"Assert.That(text1, Is.EqualTo(sog.RootPart.Text))");
433 creator = UUID.Random();
435 localID = localID + 1;
436 string name =
"West Adam";
437 byte material = (byte) random.Next((
int)SOPMaterialData.MaxMaterial);
438 ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next();
439 int pin = random.Next();
440 Byte[] partsys =
new byte[8];
441 Byte[] textani =
new byte[8];
442 random.NextBytes(textani);
443 random.NextBytes(partsys);
444 DateTime expires =
new DateTime(2010, 12, 20);
445 DateTime rezzed =
new DateTime(2005, 07, 15);
446 Vector3 groupos =
new Vector3(random.Next(),random.Next(),random.Next());
447 Vector3 offset =
new Vector3(random.Next(),random.Next(),random.Next());
448 Quaternion rotoff =
new Quaternion(random.Next(),random.Next(),random.Next(),random.Next());
449 Vector3 velocity =
new Vector3(random.Next(),random.Next(),random.Next());
450 Vector3 angvelo =
new Vector3(random.Next(),random.Next(),random.Next());
451 Vector3 accel =
new Vector3(random.Next(),random.Next(),random.Next());
452 string description = name;
453 Color color = Color.FromArgb(255, 255, 255, 0);
454 string text =
"What You Say?{]\vz~";
455 string sitname = RandomName();
456 string touchname = RandomName();
457 int linknum = random.Next();
458 byte clickaction = (byte) random.Next(127);
460 pbshap = PrimitiveBaseShape.Default;
461 Vector3 scale =
new Vector3(random.Next(),random.Next(),random.Next());
465 Assert.That(sog2,Is.Not.Null);
466 sog2.RootPart.RegionHandle = regionh;
467 sog2.RootPart.Shape = pbshap;
468 sog2.RootPart.GroupPosition = groupos;
469 sog2.RootPart.RotationOffset = rotoff;
470 sog2.RootPart.CreatorID = creator;
471 sog2.RootPart.TaskInventory = dic;
472 sog2.RootPart.Name = name;
473 sog2.RootPart.Material = material;
474 sog2.RootPart.ScriptAccessPin = pin;
475 sog2.RootPart.TextureAnimation = textani;
476 sog2.RootPart.ParticleSystem = partsys;
477 sog2.RootPart.Expires = expires;
478 sog2.RootPart.Rezzed = rezzed;
479 sog2.RootPart.OffsetPosition = offset;
480 sog2.RootPart.Velocity = velocity;
481 sog2.RootPart.AngularVelocity = angvelo;
482 sog2.RootPart.Acceleration = accel;
483 sog2.RootPart.Description = description;
484 sog2.RootPart.Color = color;
485 sog2.RootPart.Text = text;
486 sog2.RootPart.SitName = sitname;
487 sog2.RootPart.TouchName = touchname;
488 sog2.RootPart.LinkNum = linknum;
489 sog2.RootPart.ClickAction = clickaction;
490 sog2.RootPart.Scale = scale;
492 db.StoreObject(sog2, region3);
493 List<SceneObjectGroup> sogs = db.LoadObjects(region3);
494 Assert.That(sogs.Count, Is.EqualTo(1),
"Assert.That(sogs.Count, Is.EqualTo(1))");
497 Assert.That(retsog,Is.Not.Null);
499 Assert.That(regionh,Is.EqualTo(p.RegionHandle),
"Assert.That(regionh,Is.EqualTo(p.RegionHandle))");
500 Assert.That(groupos,Is.EqualTo(p.GroupPosition),
"Assert.That(groupos,Is.EqualTo(p.GroupPosition))");
501 Assert.That(name,Is.EqualTo(p.Name),
"Assert.That(name,Is.EqualTo(p.Name))");
502 Assert.That(rotoff,Is.EqualTo(p.RotationOffset),
"Assert.That(rotoff,Is.EqualTo(p.RotationOffset))");
503 Assert.That(creator,Is.EqualTo(p.CreatorID),
"Assert.That(creator,Is.EqualTo(p.CreatorID))");
504 Assert.That(dic,Is.EqualTo(p.TaskInventory),
"Assert.That(dic,Is.EqualTo(p.TaskInventory))");
505 Assert.That(name,Is.EqualTo(p.Name),
"Assert.That(name,Is.EqualTo(p.Name))");
506 Assert.That(material,Is.EqualTo(
p.Material),
"Assert.That(material,Is.EqualTo(p.Material))");
507 Assert.That(pin,Is.EqualTo(p.ScriptAccessPin),
"Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))");
508 Assert.That(textani,Is.EqualTo(p.TextureAnimation),
"Assert.That(textani,Is.EqualTo(p.TextureAnimation))");
509 Assert.That(partsys,Is.EqualTo(p.ParticleSystem),
"Assert.That(partsys,Is.EqualTo(p.ParticleSystem))");
510 Assert.That(offset,Is.EqualTo(p.OffsetPosition),
"Assert.That(offset,Is.EqualTo(p.OffsetPosition))");
511 Assert.That(velocity,Is.EqualTo(p.Velocity),
"Assert.That(velocity,Is.EqualTo(p.Velocity))");
512 Assert.That(angvelo,Is.EqualTo(p.AngularVelocity),
"Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))");
513 Assert.That(accel,Is.EqualTo(p.Acceleration),
"Assert.That(accel,Is.EqualTo(p.Acceleration))");
514 Assert.That(description,Is.EqualTo(p.Description),
"Assert.That(description,Is.EqualTo(p.Description))");
515 Assert.That(color,Is.EqualTo(p.Color),
"Assert.That(color,Is.EqualTo(p.Color))");
516 Assert.That(text,Is.EqualTo(p.Text),
"Assert.That(text,Is.EqualTo(p.Text))");
517 Assert.That(sitname,Is.EqualTo(p.SitName),
"Assert.That(sitname,Is.EqualTo(p.SitName))");
518 Assert.That(touchname,Is.EqualTo(p.TouchName),
"Assert.That(touchname,Is.EqualTo(p.TouchName))");
519 Assert.That(clickaction,Is.EqualTo(p.ClickAction),
"Assert.That(clickaction,Is.EqualTo(p.ClickAction))");
520 Assert.That(scale,Is.EqualTo(p.Scale),
"Assert.That(scale,Is.EqualTo(p.Scale))");
529 TestHelpers.InMethod();
531 UUID id = UUID.Random();
532 Dictionary<UUID, SceneObjectPart> mydic =
new Dictionary<UUID, SceneObjectPart>();
534 mydic.Add(sog.RootPart.UUID,sog.RootPart);
535 for (
int i = 0; i < 30; i++)
537 UUID tmp = UUID.Random();
539 Vector3 groupos =
new Vector3(random.Next(),random.Next(),random.Next());
540 Vector3 offset =
new Vector3(random.Next(),random.Next(),random.Next());
541 Quaternion rotoff =
new Quaternion(random.Next(),random.Next(),random.Next(),random.Next());
542 Vector3 velocity =
new Vector3(random.Next(),random.Next(),random.Next());
543 Vector3 angvelo =
new Vector3(random.Next(),random.Next(),random.Next());
544 Vector3 accel =
new Vector3(random.Next(),random.Next(),random.Next());
546 sop.GroupPosition = groupos;
547 sop.RotationOffset = rotoff;
548 sop.OffsetPosition = offset;
549 sop.Velocity = velocity;
550 sop.AngularVelocity = angvelo;
551 sop.Acceleration = accel;
557 db.StoreObject(sog, region4);
561 for (
int i = 0; i < 30; i++)
564 Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition),
"Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition))");
565 Assert.That(cursop.RotationOffset,Is.EqualTo(parts[i].RotationOffset),
"Assert.That(cursop.RotationOffset,Is.EqualTo(parts[i].RotationOffset))");
566 Assert.That(cursop.OffsetPosition,Is.EqualTo(parts[i].OffsetPosition),
"Assert.That(cursop.OffsetPosition,Is.EqualTo(parts[i].OffsetPosition))");
567 Assert.That(cursop.Velocity,Is.EqualTo(parts[i].Velocity),
"Assert.That(cursop.Velocity,Is.EqualTo(parts[i].Velocity))");
568 Assert.That(cursop.AngularVelocity,Is.EqualTo(parts[i].AngularVelocity),
"Assert.That(cursop.AngularVelocity,Is.EqualTo(parts[i].AngularVelocity))");
569 Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration),
"Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration))");
576 TestHelpers.InMethod();
578 PropertyScrambler<SceneObjectPart> scrambler =
579 new PropertyScrambler<SceneObjectPart>()
580 .DontScramble(x => x.UUID);
581 UUID tmpSog = UUID.Random();
582 UUID tmp1 = UUID.Random();
583 UUID tmp2 = UUID.Random();
584 UUID tmp3 = UUID.Random();
585 UUID newregion = UUID.Random();
589 p1.Shape = PrimitiveBaseShape.Default;
590 p2.Shape = PrimitiveBaseShape.Default;
591 p3.Shape = PrimitiveBaseShape.Default;
595 scrambler.Scramble(p1);
596 scrambler.Scramble(p2);
597 scrambler.Scramble(p3);
600 PropertyScrambler<SceneObjectGroup> sogScrambler =
601 new PropertyScrambler<SceneObjectGroup>()
602 .DontScramble(x => x.UUID);
603 sogScrambler.Scramble(sog);
610 Assert.That(parts.Length, Is.EqualTo(4),
"Assert.That(parts.Length,Is.EqualTo(4))");
612 db.StoreObject(sog, newregion);
613 List<SceneObjectGroup> sogs = db.LoadObjects(newregion);
614 Assert.That(sogs.Count, Is.EqualTo(1),
"Assert.That(sogs.Count,Is.EqualTo(1))");
618 Assert.That(newparts.Length, Is.EqualTo(4),
"Assert.That(newparts.Length,Is.EqualTo(4))");
620 Assert.That(newsog, Constraints.PropertyCompareConstraint(sog)
621 .IgnoreProperty(x=>x.LocalId)
622 .IgnoreProperty(x=>x.HasGroupChanged)
623 .IgnoreProperty(x=>x.IsSelected)
624 .IgnoreProperty(x=>x.RegionHandle)
625 .IgnoreProperty(x=>x.RegionUUID)
626 .IgnoreProperty(x=>x.Scene)
627 .IgnoreProperty(x=>x.Parts)
628 .IgnoreProperty(x=>x.RootPart));
637 sog = NewSOG(name, prim1, region1);
638 db.StoreObject(sog, region1);
651 TestHelpers.InMethod();
655 Assert.That(t, Is.Null);
662 List<TaskInventoryItem> list =
new List<TaskInventoryItem>();
666 list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid));
669 db.StorePrimInventory(sog.RootPart.UUID, list);
675 TestHelpers.InMethod();
680 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True);
682 Assert.That(t.Name, Is.EqualTo(itemname1),
"Assert.That(t.Name, Is.EqualTo(itemname1))");
687 Assert.That(sog1, Is.Not.Null);
690 Assert.That(t1, Is.Not.Null);
691 Assert.That(t1.Name, Is.EqualTo(itemname1),
"Assert.That(t.Name, Is.EqualTo(itemname1))");
694 t1.Name =
"My New Name";
695 sog1.UpdateInventoryItem(t1);
697 StoreInventory(sog1);
701 Assert.That(t2.Name, Is.EqualTo(
"My New Name"),
"Assert.That(t.Name, Is.EqualTo(\"My New Name\"))");
704 List<TaskInventoryItem> list =
new List<TaskInventoryItem>();
705 db.StorePrimInventory(prim1, list);
707 sog = FindSOG(
"object1", region1);
708 t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
709 Assert.That(t, Is.Null);
715 TestHelpers.InMethod();
718 UUID id = UUID.Random();
720 UUID folder = UUID.Random();
722 UUID owner = UUID.Random();
724 UUID creator = UUID.Random();
725 i.CreatorId = creator.ToString();
726 string name = RandomName();
728 i.Description = name;
729 UUID assetid = UUID.Random();
731 int invtype = random.Next();
733 uint nextperm = (uint) random.Next();
734 i.NextPermissions = nextperm;
735 uint curperm = (uint) random.Next();
736 i.CurrentPermissions = curperm;
737 uint baseperm = (uint) random.Next();
738 i.BasePermissions = baseperm;
739 uint eoperm = (uint) random.Next();
740 i.EveryOnePermissions = eoperm;
741 int assettype = random.Next();
742 i.AssetType = assettype;
743 UUID groupid = UUID.Random();
745 bool groupown =
true;
746 i.GroupOwned = groupown;
747 int saleprice = random.Next();
748 i.SalePrice = saleprice;
749 byte saletype = (byte) random.Next(127);
750 i.SaleType = saletype;
751 uint flags = (uint) random.Next();
753 int creationd = random.Next();
754 i.CreationDate = creationd;
757 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, i, zero), Is.True);
760 Assert.That(t.Name, Is.EqualTo(name),
"Assert.That(t.Name, Is.EqualTo(name))");
761 Assert.That(t.AssetID,Is.EqualTo(assetid),
"Assert.That(t.AssetID,Is.EqualTo(assetid))");
762 Assert.That(t.BasePermissions,Is.EqualTo(baseperm),
"Assert.That(t.BasePermissions,Is.EqualTo(baseperm))");
763 Assert.That(t.CreationDate,Is.EqualTo(creationd),
"Assert.That(t.CreationDate,Is.EqualTo(creationd))");
764 Assert.That(t.CreatorID,Is.EqualTo(creator),
"Assert.That(t.CreatorID,Is.EqualTo(creator))");
765 Assert.That(t.Description,Is.EqualTo(name),
"Assert.That(t.Description,Is.EqualTo(name))");
766 Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm),
"Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm))");
767 Assert.That(t.Flags,Is.EqualTo(flags),
"Assert.That(t.Flags,Is.EqualTo(flags))");
768 Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID),
"Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID))");
771 Assert.That(t.Type,Is.EqualTo(assettype),
"Assert.That(t.Type,Is.EqualTo(assettype))");
772 Assert.That(t.InvType, Is.EqualTo(invtype),
"Assert.That(t.InvType, Is.EqualTo(invtype))");
773 Assert.That(t.ItemID, Is.EqualTo(id),
"Assert.That(t.ItemID, Is.EqualTo(id))");
774 Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID),
"Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID))");
775 Assert.That(t.NextPermissions, Is.EqualTo(nextperm),
"Assert.That(t.NextPermissions, Is.EqualTo(nextperm))");
778 Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID),
"Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID))");
780 Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID),
"Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))");
781 Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID),
"Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))");
785 [ExpectedException(typeof(ArgumentException))]
788 TestHelpers.InMethod();
802 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib1, zero), Is.True);
803 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib2, zero), Is.True);
804 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib3, zero), Is.True);
805 Assert.That(sog.AddInventoryItem(zero, sog.RootPart.LocalId, ib4, zero), Is.True);
808 Assert.That(t1.Name, Is.EqualTo(ib1.Name),
"Assert.That(t1.Name, Is.EqualTo(ib1.Name))");
810 Assert.That(t2.Name, Is.EqualTo(ib2.Name),
"Assert.That(t2.Name, Is.EqualTo(ib2.Name))");
812 Assert.That(t3.Name, Is.EqualTo(ib3.Name),
"Assert.That(t3.Name, Is.EqualTo(ib3.Name))");
814 Assert.That(t4, Is.Null);
820 TestHelpers.InMethod();
822 db.RemoveObject(prim1, region1);
824 Assert.That(sog, Is.Null);
830 TestHelpers.InMethod();
833 Assert.That(r1.RegionUUID, Is.EqualTo(region1),
"Assert.That(r1.RegionUUID, Is.EqualTo(region1))");
836 Assert.That(r2.RegionUUID, Is.EqualTo(region2),
"Assert.That(r2.RegionUUID, Is.EqualTo(region2))");
842 TestHelpers.InMethod();
844 int agentlimit = random.Next();
845 double objectbonus = random.Next();
846 int maturity = random.Next();
847 UUID tertex1 = UUID.Random();
848 UUID tertex2 = UUID.Random();
849 UUID tertex3 = UUID.Random();
850 UUID tertex4 = UUID.Random();
851 double elev1nw = random.Next();
852 double elev2nw = random.Next();
853 double elev1ne = random.Next();
854 double elev2ne = random.Next();
855 double elev1se = random.Next();
856 double elev2se = random.Next();
857 double elev1sw = random.Next();
858 double elev2sw = random.Next();
859 double waterh = random.Next();
860 double terrainraise = random.Next();
861 double terrainlower = random.Next();
862 Vector3 sunvector =
new Vector3((
float)Math.Round(random.NextDouble(),5),(
float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
863 UUID terimgid = UUID.Random();
864 double sunpos = random.Next();
865 UUID cov = UUID.Random();
868 r1.BlockTerraform =
true;
870 r1.AllowDamage =
true;
871 r1.RestrictPushing =
true;
872 r1.AllowLandResell =
false;
873 r1.AllowLandJoinDivide =
false;
874 r1.BlockShowInSearch =
true;
875 r1.AgentLimit = agentlimit;
876 r1.ObjectBonus = objectbonus;
877 r1.Maturity = maturity;
878 r1.DisableScripts =
true;
879 r1.DisableCollisions =
true;
880 r1.DisablePhysics =
true;
881 r1.TerrainTexture1 = tertex1;
882 r1.TerrainTexture2 = tertex2;
883 r1.TerrainTexture3 = tertex3;
884 r1.TerrainTexture4 = tertex4;
885 r1.Elevation1NW = elev1nw;
886 r1.Elevation2NW = elev2nw;
887 r1.Elevation1NE = elev1ne;
888 r1.Elevation2NE = elev2ne;
889 r1.Elevation1SE = elev1se;
890 r1.Elevation2SE = elev2se;
891 r1.Elevation1SW = elev1sw;
892 r1.Elevation2SW = elev2sw;
893 r1.WaterHeight = waterh;
894 r1.TerrainRaiseLimit = terrainraise;
895 r1.TerrainLowerLimit = terrainlower;
896 r1.UseEstateSun =
false;
898 r1.SunVector = sunvector;
899 r1.TerrainImageID = terimgid;
901 r1.SunPosition = sunpos;
904 db.StoreRegionSettings(r1);
907 Assert.That(r1a.RegionUUID, Is.EqualTo(region1),
"Assert.That(r1a.RegionUUID, Is.EqualTo(region1))");
908 Assert.That(r1a.BlockTerraform,Is.True);
909 Assert.That(r1a.BlockFly,Is.True);
910 Assert.That(r1a.AllowDamage,Is.True);
911 Assert.That(r1a.RestrictPushing,Is.True);
912 Assert.That(r1a.AllowLandResell,Is.False);
913 Assert.That(r1a.AllowLandJoinDivide,Is.False);
914 Assert.That(r1a.BlockShowInSearch,Is.True);
915 Assert.That(r1a.AgentLimit,Is.EqualTo(agentlimit),
"Assert.That(r1a.AgentLimit,Is.EqualTo(agentlimit))");
916 Assert.That(r1a.ObjectBonus,Is.EqualTo(objectbonus),
"Assert.That(r1a.ObjectBonus,Is.EqualTo(objectbonus))");
917 Assert.That(r1a.Maturity,Is.EqualTo(maturity),
"Assert.That(r1a.Maturity,Is.EqualTo(maturity))");
918 Assert.That(r1a.DisableScripts,Is.True);
919 Assert.That(r1a.DisableCollisions,Is.True);
920 Assert.That(r1a.DisablePhysics,Is.True);
921 Assert.That(r1a.TerrainTexture1,Is.EqualTo(tertex1),
"Assert.That(r1a.TerrainTexture1,Is.EqualTo(tertex1))");
922 Assert.That(r1a.TerrainTexture2,Is.EqualTo(tertex2),
"Assert.That(r1a.TerrainTexture2,Is.EqualTo(tertex2))");
923 Assert.That(r1a.TerrainTexture3,Is.EqualTo(tertex3),
"Assert.That(r1a.TerrainTexture3,Is.EqualTo(tertex3))");
924 Assert.That(r1a.TerrainTexture4,Is.EqualTo(tertex4),
"Assert.That(r1a.TerrainTexture4,Is.EqualTo(tertex4))");
925 Assert.That(r1a.Elevation1NW,Is.EqualTo(elev1nw),
"Assert.That(r1a.Elevation1NW,Is.EqualTo(elev1nw))");
926 Assert.That(r1a.Elevation2NW,Is.EqualTo(elev2nw),
"Assert.That(r1a.Elevation2NW,Is.EqualTo(elev2nw))");
927 Assert.That(r1a.Elevation1NE,Is.EqualTo(elev1ne),
"Assert.That(r1a.Elevation1NE,Is.EqualTo(elev1ne))");
928 Assert.That(r1a.Elevation2NE,Is.EqualTo(elev2ne),
"Assert.That(r1a.Elevation2NE,Is.EqualTo(elev2ne))");
929 Assert.That(r1a.Elevation1SE,Is.EqualTo(elev1se),
"Assert.That(r1a.Elevation1SE,Is.EqualTo(elev1se))");
930 Assert.That(r1a.Elevation2SE,Is.EqualTo(elev2se),
"Assert.That(r1a.Elevation2SE,Is.EqualTo(elev2se))");
931 Assert.That(r1a.Elevation1SW,Is.EqualTo(elev1sw),
"Assert.That(r1a.Elevation1SW,Is.EqualTo(elev1sw))");
932 Assert.That(r1a.Elevation2SW,Is.EqualTo(elev2sw),
"Assert.That(r1a.Elevation2SW,Is.EqualTo(elev2sw))");
933 Assert.That(r1a.WaterHeight,Is.EqualTo(waterh),
"Assert.That(r1a.WaterHeight,Is.EqualTo(waterh))");
934 Assert.That(r1a.TerrainRaiseLimit,Is.EqualTo(terrainraise),
"Assert.That(r1a.TerrainRaiseLimit,Is.EqualTo(terrainraise))");
935 Assert.That(r1a.TerrainLowerLimit,Is.EqualTo(terrainlower),
"Assert.That(r1a.TerrainLowerLimit,Is.EqualTo(terrainlower))");
936 Assert.That(r1a.UseEstateSun,Is.False);
937 Assert.That(r1a.Sandbox,Is.True);
938 Assert.That(r1a.SunVector,Is.EqualTo(sunvector),
"Assert.That(r1a.SunVector,Is.EqualTo(sunvector))");
940 Assert.That(r1a.FixedSun,Is.True);
941 Assert.That(r1a.SunPosition, Is.EqualTo(sunpos),
"Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))");
942 Assert.That(r1a.Covenant, Is.EqualTo(cov),
"Assert.That(r1a.Covenant, Is.EqualTo(cov))");
948 TestHelpers.InMethod();
950 Assert.That(db.LoadTerrain(zero), Is.Null);
951 Assert.That(db.LoadTerrain(region1), Is.Null);
952 Assert.That(db.LoadTerrain(region2), Is.Null);
953 Assert.That(db.LoadTerrain(UUID.Random()), Is.Null);
959 TestHelpers.InMethod();
961 double[,] t1 = GenTerrain(height1);
962 db.StoreTerrain(t1, region1);
967 Assert.That(db.LoadTerrain(zero), Is.Null);
968 Assert.That(db.LoadTerrain(region1), Is.Not.Null);
969 Assert.That(db.LoadTerrain(region2), Is.Null);
970 Assert.That(db.LoadTerrain(UUID.Random()), Is.Null);
976 TestHelpers.InMethod();
978 double[,] baseterrain1 = GenTerrain(height1);
979 double[,] baseterrain2 = GenTerrain(height2);
980 double[,] t1 = db.LoadTerrain(region1);
981 Assert.That(CompareTerrain(t1, baseterrain1), Is.True);
982 Assert.That(CompareTerrain(t1, baseterrain2), Is.False);
988 TestHelpers.InMethod();
990 double[,] baseterrain1 = GenTerrain(height1);
991 double[,] baseterrain2 = GenTerrain(height2);
992 db.StoreTerrain(baseterrain2, region1);
997 double[,] t1 = db.LoadTerrain(region1);
998 Assert.That(CompareTerrain(t1, baseterrain1), Is.False);
999 Assert.That(CompareTerrain(t1, baseterrain2), Is.True);
1005 TestHelpers.InMethod();
1007 Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0),
"Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))");
1008 Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0),
"Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))");
1009 Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0),
"Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))");
1010 Assert.That(db.LoadLandObjects(UUID.Random()).Count, Is.EqualTo(0),
"Assert.That(db.LoadLandObjects(UUID.Random()).Count, Is.EqualTo(0))");
1021 private double[,] GenTerrain(
double value)
1023 double[,] terret =
new double[Constants.RegionSize, Constants.RegionSize];
1024 terret.Initialize();
1025 for (
int x = 0; x < Constants.RegionSize; x++)
1026 for (
int y = 0; y < Constants.RegionSize; y++)
1027 terret[x,y] = value;
1032 private bool CompareTerrain(
double[,] one,
double[,] two)
1034 for (
int x = 0; x < Constants.RegionSize; x++)
1035 for (
int y = 0; y < Constants.RegionSize; y++)
1036 if (one[x,y] != two[x,y])
1044 List<SceneObjectGroup> objs = db.LoadObjects(r);
1046 if (sog.
Name == name)
1067 regionInfo.RegionID = regionId;
1068 regionInfo.RegionLocX = 0;
1069 regionInfo.RegionLocY = 0;
1073 sop.Description = name;
1074 sop.Text = RandomName();
1075 sop.SitName = RandomName();
1076 sop.TouchName = RandomName();
1078 sop.Shape = PrimitiveBaseShape.Default;
1090 sop.Description = name;
1091 sop.Text = RandomName();
1092 sop.SitName = RandomName();
1093 sop.TouchName = RandomName();
1095 sop.Shape = PrimitiveBaseShape.Default;
1101 private InventoryItemBase NewItem(UUID
id, UUID parent, UUID owner,
string name, UUID asset)
1107 i.CreatorId = owner.ToString();
1109 i.Description = name;
1114 private static string RandomName()
1116 StringBuilder name =
new StringBuilder();
1117 int size = random.Next(5,12);
1119 for (
int i=0; i<size; i++)
1121 ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
1124 return name.ToString();
void T015_LargeSceneObjects()
Test storage and retrieval of a scene object with a large number of parts.
void T303_UpdateTerrain()
void T020_PrimInventoryEmpty()
IEntityInventory Inventory
This part's inventory
OpenSim.Framework.RegionInfo RegionInfo
void T021_PrimInventoryBasic()
RegionTests(bool rebuild)
A dictionary containing task inventory items. Indexed by item UUID.
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
PrimFlags Flags
Property flags. See OpenMetaverse.PrimFlags
void T026_PrimInventoryMany()
Represents an item in a task inventory
RegionTests(string conn, bool rebuild)
void T016_RandomSogWithSceneParts()
void T025_PrimInventoryPersistency()
Inventory Item - contains all the properties associated with an individual inventory piece...
override void InitService(object service)
To be overridden in derived classes. Do whatever init with the m_service, like setting the conn strin...
void T013_DatabasePersistency()
void T101_UpdateRegionInfo()
List< UUID > GetInventoryList()
Get the uuids of all items in this inventory
Material
Material type for a primitive
void T301_CreateTerrain()
void T100_DefaultRegionInfo()
override string Name
The name of an object grouping is always the same as its root part
void T010_StoreSimpleObject()