Corrections in RegionTests.cs. It now fully works!
The problem was that some tests relied on prior tests to leave the DB in a particular state, but the test class cleared the DB every time. The affected tests have been merged into one to remove the dependencies. tested on all 3 Dbs, all tests green.soprefactor
parent
6322a085b3
commit
94f4c20866
|
@ -60,6 +60,8 @@ namespace OpenSim.Data.Tests
|
||||||
where TConn : DbConnection, new()
|
where TConn : DbConnection, new()
|
||||||
where TRegStore : class, IRegionDataStore, new()
|
where TRegStore : class, IRegionDataStore, new()
|
||||||
{
|
{
|
||||||
|
bool m_rebuildDB;
|
||||||
|
|
||||||
public IRegionDataStore db;
|
public IRegionDataStore db;
|
||||||
public UUID zero = UUID.Zero;
|
public UUID zero = UUID.Zero;
|
||||||
public UUID region1 = UUID.Random();
|
public UUID region1 = UUID.Random();
|
||||||
|
@ -85,6 +87,16 @@ namespace OpenSim.Data.Tests
|
||||||
public double height1 = 20;
|
public double height1 = 20;
|
||||||
public double height2 = 100;
|
public double height2 = 100;
|
||||||
|
|
||||||
|
public RegionTests(string conn, bool rebuild)
|
||||||
|
: base(conn)
|
||||||
|
{
|
||||||
|
m_rebuildDB = rebuild;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegionTests() : this("", false) { }
|
||||||
|
public RegionTests(string conn) : this(conn, false) {}
|
||||||
|
public RegionTests(bool rebuild): this("", rebuild) {}
|
||||||
|
|
||||||
|
|
||||||
protected override void InitService(object service)
|
protected override void InitService(object service)
|
||||||
{
|
{
|
||||||
|
@ -93,22 +105,17 @@ namespace OpenSim.Data.Tests
|
||||||
ClearDB();
|
ClearDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ClearDB()
|
private void ClearDB()
|
||||||
{
|
{
|
||||||
// if a new table is added, it has to be dropped here
|
string[] reg_tables = new string[] {
|
||||||
ExecuteSql("delete from migrations where name='RegionStore';");
|
"prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings"
|
||||||
|
};
|
||||||
DropTables(
|
if (m_rebuildDB)
|
||||||
"prims",
|
{
|
||||||
"primshapes",
|
DropTables(reg_tables);
|
||||||
"primitems",
|
ResetMigrations("RegionStore");
|
||||||
"terrain",
|
}else
|
||||||
"land",
|
ClearTables(reg_tables);
|
||||||
"landaccesslist",
|
|
||||||
"regionban",
|
|
||||||
"regionsettings"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -602,68 +609,88 @@ namespace OpenSim.Data.Tests
|
||||||
.IgnoreProperty(x=>x.RootPart));
|
.IgnoreProperty(x=>x.RootPart));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private SceneObjectGroup GetMySOG(string name)
|
||||||
|
{
|
||||||
|
SceneObjectGroup sog = FindSOG(name, region1);
|
||||||
|
if (sog == null)
|
||||||
|
{
|
||||||
|
sog = NewSOG(name, prim1, region1);
|
||||||
|
db.StoreObject(sog, region1);
|
||||||
|
}
|
||||||
|
return sog;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: it is a bad practice to rely on some of the previous tests having been run before.
|
||||||
|
// If the tests are run manually, one at a time, each starts with full class init (DB cleared).
|
||||||
|
// Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order.
|
||||||
|
// We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*!
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void T020_PrimInventoryEmpty()
|
public void T020_PrimInventoryEmpty()
|
||||||
{
|
{
|
||||||
SceneObjectGroup sog = FindSOG("object1", region1);
|
SceneObjectGroup sog = GetMySOG("object1");
|
||||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
||||||
Assert.That(t, Is.Null);
|
Assert.That(t, Is.Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
// TODO: Is there any point to call StorePrimInventory on a list, rather than on the prim itself?
|
||||||
public void T021_PrimInventoryStore()
|
|
||||||
|
private void StoreInventory(SceneObjectGroup sog)
|
||||||
{
|
{
|
||||||
SceneObjectGroup sog = FindSOG("object1", region1);
|
List<TaskInventoryItem> list = new List<TaskInventoryItem>();
|
||||||
|
// TODO: seriously??? this is the way we need to loop to get this?
|
||||||
|
foreach (UUID uuid in sog.RootPart.Inventory.GetInventoryList())
|
||||||
|
{
|
||||||
|
list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
db.StorePrimInventory(sog.RootPart.UUID, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void T021_PrimInventoryBasic()
|
||||||
|
{
|
||||||
|
SceneObjectGroup sog = GetMySOG("object1");
|
||||||
InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero);
|
InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero);
|
||||||
|
|
||||||
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
|
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
|
||||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
||||||
Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
|
Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
|
||||||
|
|
||||||
// TODO: seriously??? this is the way we need to loop to get this?
|
StoreInventory(sog);
|
||||||
|
|
||||||
List<TaskInventoryItem> list = new List<TaskInventoryItem>();
|
SceneObjectGroup sog1 = FindSOG("object1", region1);
|
||||||
foreach (UUID uuid in sog.RootPart.Inventory.GetInventoryList())
|
Assert.That(sog1, Is.Not.Null);
|
||||||
{
|
|
||||||
list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid));
|
|
||||||
}
|
|
||||||
|
|
||||||
db.StorePrimInventory(prim1, list);
|
TaskInventoryItem t1 = sog1.GetInventoryItem(sog1.RootPart.LocalId, item1);
|
||||||
}
|
Assert.That(t1, Is.Not.Null);
|
||||||
|
Assert.That(t1.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
|
||||||
|
|
||||||
[Test]
|
// Updating inventory
|
||||||
public void T022_PrimInventoryRetrieve()
|
t1.Name = "My New Name";
|
||||||
{
|
sog1.UpdateInventoryItem(t1);
|
||||||
SceneObjectGroup sog = FindSOG("object1", region1);
|
|
||||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
|
||||||
|
|
||||||
Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
|
StoreInventory(sog1);
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
SceneObjectGroup sog2 = FindSOG("object1", region1);
|
||||||
public void T023_PrimInventoryUpdate()
|
TaskInventoryItem t2 = sog2.GetInventoryItem(sog2.RootPart.LocalId, item1);
|
||||||
{
|
Assert.That(t2.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))");
|
||||||
SceneObjectGroup sog = FindSOG("object1", region1);
|
|
||||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
|
||||||
|
|
||||||
t.Name = "My New Name";
|
// Removing inventory
|
||||||
sog.UpdateInventoryItem(t);
|
|
||||||
|
|
||||||
Assert.That(t.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void T024_PrimInventoryRemove()
|
|
||||||
{
|
|
||||||
List<TaskInventoryItem> list = new List<TaskInventoryItem>();
|
List<TaskInventoryItem> list = new List<TaskInventoryItem>();
|
||||||
db.StorePrimInventory(prim1, list);
|
db.StorePrimInventory(prim1, list);
|
||||||
|
|
||||||
SceneObjectGroup sog = FindSOG("object1", region1);
|
sog = FindSOG("object1", region1);
|
||||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
||||||
Assert.That(t, Is.Null);
|
Assert.That(t, Is.Null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void T025_PrimInventoryPersistency()
|
public void T025_PrimInventoryPersistency()
|
||||||
{
|
{
|
||||||
|
@ -706,7 +733,7 @@ namespace OpenSim.Data.Tests
|
||||||
int creationd = random.Next();
|
int creationd = random.Next();
|
||||||
i.CreationDate = creationd;
|
i.CreationDate = creationd;
|
||||||
|
|
||||||
SceneObjectGroup sog = FindSOG("object1", region1);
|
SceneObjectGroup sog = GetMySOG("object1");
|
||||||
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
|
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
|
||||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id);
|
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue