mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 19:36:07 +08:00
move the actual [Test] methods for databases to OpenSim.Data.Tests
classes. This did mean loosing 1 unit test that was actually testing an sqlite function directly instead of the interface.
This commit is contained in:
@@ -30,6 +30,7 @@ using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.SyntaxHelpers;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Data.Tests;
|
||||
using OpenSim.Data.SQLite;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenMetaverse;
|
||||
@@ -37,16 +38,15 @@ using OpenMetaverse;
|
||||
namespace OpenSim.Data.SQLite.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class SQLiteRegionTest
|
||||
public class SQLiteRegionTest : BasicRegionTest
|
||||
{
|
||||
public string file = "regiontest.db";
|
||||
public string connect;
|
||||
public SQLiteRegionData db;
|
||||
public UUID region = UUID.Zero;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
SuperInit();
|
||||
connect = "URI=file:" + file + ",version=3";
|
||||
db = new SQLiteRegionData();
|
||||
db.Initialise(connect);
|
||||
@@ -57,94 +57,5 @@ namespace OpenSim.Data.SQLite.Tests
|
||||
{
|
||||
System.IO.File.Delete(file);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void T001_LoadEmpty()
|
||||
{
|
||||
List<SceneObjectGroup> objs = db.LoadObjects(region);
|
||||
Assert.AreEqual(0, objs.Count);
|
||||
}
|
||||
|
||||
// SOG round trips
|
||||
// * store objects, make sure they save
|
||||
// * update
|
||||
|
||||
[Test]
|
||||
public void T010_StoreSimpleObject()
|
||||
{
|
||||
SceneObjectGroup sog = NewSOG("object1");
|
||||
SceneObjectGroup sog2 = NewSOG("object2");
|
||||
|
||||
db.StoreObject(sog, region);
|
||||
db.StoreObject(sog2, region);
|
||||
|
||||
// This tests the ADO.NET driver
|
||||
List<SceneObjectGroup> objs = db.LoadObjects(region);
|
||||
Assert.AreEqual(2, objs.Count);
|
||||
|
||||
// This confirms things actually went to disk
|
||||
db = new SQLiteRegionData();
|
||||
db.Initialise(connect);
|
||||
|
||||
List<SceneObjectGroup> objs2 = db.LoadObjects(region);
|
||||
Assert.AreEqual(2, objs2.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void T011_ObjectNames()
|
||||
{
|
||||
List<SceneObjectGroup> objs = db.LoadObjects(region);
|
||||
foreach (SceneObjectGroup sog in objs)
|
||||
{
|
||||
SceneObjectPart p = sog.RootPart;
|
||||
Assert.That("", Text.DoesNotMatch(p.Name));
|
||||
Assert.That(p.Name, Text.Matches(p.Description));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void T012_UpdateObject()
|
||||
{
|
||||
string text = "object1 text";
|
||||
SceneObjectGroup sog = FindSOG("object1", region);
|
||||
sog.RootPart.Text = text;
|
||||
db.StoreObject(sog, region);
|
||||
|
||||
sog = FindSOG("object1", region);
|
||||
Assert.That(text, Text.Matches(sog.RootPart.Text));
|
||||
}
|
||||
|
||||
// Extra private methods
|
||||
|
||||
private SceneObjectGroup FindSOG(string name, UUID r)
|
||||
{
|
||||
List<SceneObjectGroup> objs = db.LoadObjects(r);
|
||||
foreach (SceneObjectGroup sog in objs)
|
||||
{
|
||||
SceneObjectPart p = sog.RootPart;
|
||||
if (p.Name == name) {
|
||||
return sog;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private SceneObjectGroup NewSOG(string name)
|
||||
{
|
||||
SceneObjectGroup sog = new SceneObjectGroup();
|
||||
SceneObjectPart sop = new SceneObjectPart();
|
||||
sop.LocalId = 1;
|
||||
sop.Name = name;
|
||||
sop.Description = name;
|
||||
sop.Text = "";
|
||||
sop.SitName = "";
|
||||
sop.TouchName = "";
|
||||
sop.UUID = UUID.Random();
|
||||
sop.Shape = PrimitiveBaseShape.Default;
|
||||
sog.AddPart(sop);
|
||||
sog.RootPart = sop;
|
||||
return sog;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user