aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs
diff options
context:
space:
mode:
authorSean Dague2008-09-12 18:13:43 +0000
committerSean Dague2008-09-12 18:13:43 +0000
commit9349cf314963a2b74727b86e37b41642c7212d6d (patch)
treee52240f71b1bce3531649ce1629e1b62219f6827 /OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs
parentchange order in prebuild.xml so this works in nant on a clean (diff)
downloadopensim-SC_OLD-9349cf314963a2b74727b86e37b41642c7212d6d.zip
opensim-SC_OLD-9349cf314963a2b74727b86e37b41642c7212d6d.tar.gz
opensim-SC_OLD-9349cf314963a2b74727b86e37b41642c7212d6d.tar.bz2
opensim-SC_OLD-9349cf314963a2b74727b86e37b41642c7212d6d.tar.xz
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.
Diffstat (limited to 'OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs')
-rw-r--r--OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs95
1 files changed, 3 insertions, 92 deletions
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs b/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs
index 2e93fd6..94b5bf1 100644
--- a/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs
+++ b/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers; 31using NUnit.Framework.SyntaxHelpers;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Data.Tests;
33using OpenSim.Data.SQLite; 34using OpenSim.Data.SQLite;
34using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
35using OpenMetaverse; 36using OpenMetaverse;
@@ -37,16 +38,15 @@ using OpenMetaverse;
37namespace OpenSim.Data.SQLite.Tests 38namespace OpenSim.Data.SQLite.Tests
38{ 39{
39 [TestFixture] 40 [TestFixture]
40 public class SQLiteRegionTest 41 public class SQLiteRegionTest : BasicRegionTest
41 { 42 {
42 public string file = "regiontest.db"; 43 public string file = "regiontest.db";
43 public string connect; 44 public string connect;
44 public SQLiteRegionData db;
45 public UUID region = UUID.Zero;
46 45
47 [TestFixtureSetUp] 46 [TestFixtureSetUp]
48 public void Init() 47 public void Init()
49 { 48 {
49 SuperInit();
50 connect = "URI=file:" + file + ",version=3"; 50 connect = "URI=file:" + file + ",version=3";
51 db = new SQLiteRegionData(); 51 db = new SQLiteRegionData();
52 db.Initialise(connect); 52 db.Initialise(connect);
@@ -57,94 +57,5 @@ namespace OpenSim.Data.SQLite.Tests
57 { 57 {
58 System.IO.File.Delete(file); 58 System.IO.File.Delete(file);
59 } 59 }
60
61 [Test]
62 public void T001_LoadEmpty()
63 {
64 List<SceneObjectGroup> objs = db.LoadObjects(region);
65 Assert.AreEqual(0, objs.Count);
66 }
67
68 // SOG round trips
69 // * store objects, make sure they save
70 // * update
71
72 [Test]
73 public void T010_StoreSimpleObject()
74 {
75 SceneObjectGroup sog = NewSOG("object1");
76 SceneObjectGroup sog2 = NewSOG("object2");
77
78 db.StoreObject(sog, region);
79 db.StoreObject(sog2, region);
80
81 // This tests the ADO.NET driver
82 List<SceneObjectGroup> objs = db.LoadObjects(region);
83 Assert.AreEqual(2, objs.Count);
84
85 // This confirms things actually went to disk
86 db = new SQLiteRegionData();
87 db.Initialise(connect);
88
89 List<SceneObjectGroup> objs2 = db.LoadObjects(region);
90 Assert.AreEqual(2, objs2.Count);
91 }
92
93 [Test]
94 public void T011_ObjectNames()
95 {
96 List<SceneObjectGroup> objs = db.LoadObjects(region);
97 foreach (SceneObjectGroup sog in objs)
98 {
99 SceneObjectPart p = sog.RootPart;
100 Assert.That("", Text.DoesNotMatch(p.Name));
101 Assert.That(p.Name, Text.Matches(p.Description));
102 }
103 }
104
105 [Test]
106 public void T012_UpdateObject()
107 {
108 string text = "object1 text";
109 SceneObjectGroup sog = FindSOG("object1", region);
110 sog.RootPart.Text = text;
111 db.StoreObject(sog, region);
112
113 sog = FindSOG("object1", region);
114 Assert.That(text, Text.Matches(sog.RootPart.Text));
115 }
116
117 // Extra private methods
118
119 private SceneObjectGroup FindSOG(string name, UUID r)
120 {
121 List<SceneObjectGroup> objs = db.LoadObjects(r);
122 foreach (SceneObjectGroup sog in objs)
123 {
124 SceneObjectPart p = sog.RootPart;
125 if (p.Name == name) {
126 return sog;
127 }
128 }
129 return null;
130 }
131
132 private SceneObjectGroup NewSOG(string name)
133 {
134 SceneObjectGroup sog = new SceneObjectGroup();
135 SceneObjectPart sop = new SceneObjectPart();
136 sop.LocalId = 1;
137 sop.Name = name;
138 sop.Description = name;
139 sop.Text = "";
140 sop.SitName = "";
141 sop.TouchName = "";
142 sop.UUID = UUID.Random();
143 sop.Shape = PrimitiveBaseShape.Default;
144 sog.AddPart(sop);
145 sog.RootPart = sop;
146 return sog;
147 }
148
149 } 60 }
150} \ No newline at end of file 61} \ No newline at end of file