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 TRegStore : class, IRegionDataStore, new()
|
||||
{
|
||||
bool m_rebuildDB;
|
||||
|
||||
public IRegionDataStore db;
|
||||
public UUID zero = UUID.Zero;
|
||||
public UUID region1 = UUID.Random();
|
||||
|
@ -85,6 +87,16 @@ namespace OpenSim.Data.Tests
|
|||
public double height1 = 20;
|
||||
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)
|
||||
{
|
||||
|
@ -93,22 +105,17 @@ namespace OpenSim.Data.Tests
|
|||
ClearDB();
|
||||
}
|
||||
|
||||
|
||||
private void ClearDB()
|
||||
{
|
||||
// if a new table is added, it has to be dropped here
|
||||
ExecuteSql("delete from migrations where name='RegionStore';");
|
||||
|
||||
DropTables(
|
||||
"prims",
|
||||
"primshapes",
|
||||
"primitems",
|
||||
"terrain",
|
||||
"land",
|
||||
"landaccesslist",
|
||||
"regionban",
|
||||
"regionsettings"
|
||||
);
|
||||
string[] reg_tables = new string[] {
|
||||
"prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings"
|
||||
};
|
||||
if (m_rebuildDB)
|
||||
{
|
||||
DropTables(reg_tables);
|
||||
ResetMigrations("RegionStore");
|
||||
}else
|
||||
ClearTables(reg_tables);
|
||||
}
|
||||
|
||||
|
||||
|
@ -602,68 +609,88 @@ namespace OpenSim.Data.Tests
|
|||
.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]
|
||||
public void T020_PrimInventoryEmpty()
|
||||
{
|
||||
SceneObjectGroup sog = FindSOG("object1", region1);
|
||||
SceneObjectGroup sog = GetMySOG("object1");
|
||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
||||
Assert.That(t, Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void T021_PrimInventoryStore()
|
||||
// TODO: Is there any point to call StorePrimInventory on a list, rather than on the prim itself?
|
||||
|
||||
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);
|
||||
|
||||
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
|
||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
||||
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>();
|
||||
foreach (UUID uuid in sog.RootPart.Inventory.GetInventoryList())
|
||||
{
|
||||
list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid));
|
||||
}
|
||||
SceneObjectGroup sog1 = FindSOG("object1", region1);
|
||||
Assert.That(sog1, Is.Not.Null);
|
||||
|
||||
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]
|
||||
public void T022_PrimInventoryRetrieve()
|
||||
{
|
||||
SceneObjectGroup sog = FindSOG("object1", region1);
|
||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
||||
// Updating inventory
|
||||
t1.Name = "My New Name";
|
||||
sog1.UpdateInventoryItem(t1);
|
||||
|
||||
Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))");
|
||||
}
|
||||
StoreInventory(sog1);
|
||||
|
||||
[Test]
|
||||
public void T023_PrimInventoryUpdate()
|
||||
{
|
||||
SceneObjectGroup sog = FindSOG("object1", region1);
|
||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
||||
SceneObjectGroup sog2 = FindSOG("object1", region1);
|
||||
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\"))");
|
||||
|
||||
t.Name = "My New Name";
|
||||
sog.UpdateInventoryItem(t);
|
||||
// Removing inventory
|
||||
|
||||
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>();
|
||||
db.StorePrimInventory(prim1, list);
|
||||
|
||||
SceneObjectGroup sog = FindSOG("object1", region1);
|
||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
||||
sog = FindSOG("object1", region1);
|
||||
t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
|
||||
Assert.That(t, Is.Null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void T025_PrimInventoryPersistency()
|
||||
{
|
||||
|
@ -706,7 +733,7 @@ namespace OpenSim.Data.Tests
|
|||
int creationd = random.Next();
|
||||
i.CreationDate = creationd;
|
||||
|
||||
SceneObjectGroup sog = FindSOG("object1", region1);
|
||||
SceneObjectGroup sog = GetMySOG("object1");
|
||||
Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True);
|
||||
TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id);
|
||||
|
||||
|
|
Loading…
Reference in New Issue