aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/Tests
diff options
context:
space:
mode:
authorSean Dague2008-09-12 16:05:06 +0000
committerSean Dague2008-09-12 16:05:06 +0000
commit96c720b04a7e96b4ebcada71484d183f503a785e (patch)
tree775940e0797201e18f4ef179e8b8fb20ca3aa102 /OpenSim/Data/SQLite/Tests
parentadd the m_host.AddScriptLPS(1); line. I'm not actually sure what it (diff)
downloadopensim-SC_OLD-96c720b04a7e96b4ebcada71484d183f503a785e.zip
opensim-SC_OLD-96c720b04a7e96b4ebcada71484d183f503a785e.tar.gz
opensim-SC_OLD-96c720b04a7e96b4ebcada71484d183f503a785e.tar.bz2
opensim-SC_OLD-96c720b04a7e96b4ebcada71484d183f503a785e.tar.xz
be more clever and move the bulk of the db tests for inventory into
OpenSim.Data.Tests, then subclass with custom init bits for sqlite. As I've only been testing the plugin interfaces anyway, this should make it very easy to write only a little bit of code to use these tests for other databases. It will also give us the framework for definining the datastore behavior and making sure that all the databases do the same thing.
Diffstat (limited to 'OpenSim/Data/SQLite/Tests')
-rw-r--r--OpenSim/Data/SQLite/Tests/SQLiteInventoryTest.cs143
1 files changed, 3 insertions, 140 deletions
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteInventoryTest.cs b/OpenSim/Data/SQLite/Tests/SQLiteInventoryTest.cs
index 4bc1b9a..ee6732b 100644
--- a/OpenSim/Data/SQLite/Tests/SQLiteInventoryTest.cs
+++ b/OpenSim/Data/SQLite/Tests/SQLiteInventoryTest.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,38 +38,18 @@ using OpenMetaverse;
37namespace OpenSim.Data.SQLite.Tests 38namespace OpenSim.Data.SQLite.Tests
38{ 39{
39 [TestFixture] 40 [TestFixture]
40 public class SQLiteInventoryTest 41 public class SQLiteInventoryTest : BasicInventoryTest
41 { 42 {
42 public string file = "inventorytest.db"; 43 public string file = "inventorytest.db";
43 public string connect; 44 public string connect;
44 public SQLiteInventoryStore db;
45 public UUID zero = UUID.Zero;
46 public UUID uuid1;
47 public UUID uuid2;
48 public UUID uuid3;
49 public UUID owner1;
50 public UUID owner2;
51 public UUID owner3;
52 public string name1;
53 public string name2;
54 public string name3;
55
56 45
57 [TestFixtureSetUp] 46 [TestFixtureSetUp]
58 public void Init() 47 public void Init()
59 { 48 {
49 SuperInit();
60 connect = "URI=file:" + file + ",version=3"; 50 connect = "URI=file:" + file + ",version=3";
61 db = new SQLiteInventoryStore(); 51 db = new SQLiteInventoryStore();
62 db.Initialise(connect); 52 db.Initialise(connect);
63 uuid1 = UUID.Random();
64 uuid2 = UUID.Random();
65 uuid3 = UUID.Random();
66 owner1 = UUID.Random();
67 owner2 = UUID.Random();
68 owner3 = UUID.Random();
69 name1 = "Root Folder for " + owner1.ToString();
70 name2 = "First Level folder";
71 name3 = "First Level folder 2";
72 } 53 }
73 54
74 [TestFixtureTearDown] 55 [TestFixtureTearDown]
@@ -76,123 +57,5 @@ namespace OpenSim.Data.SQLite.Tests
76 { 57 {
77 System.IO.File.Delete(file); 58 System.IO.File.Delete(file);
78 } 59 }
79
80 [Test]
81 public void T001_LoadEmpty()
82 {
83 Assert.That(db.getInventoryItem(uuid1), Is.Null);
84 Assert.That(db.getUserRootFolder(owner1), Is.Null);
85 }
86
87 // 01x - folder tests
88 [Test]
89 public void T010_FolderNonParent()
90 {
91 InventoryFolderBase f1 = NewFolder(uuid2, uuid1, owner1, name2);
92 // the folder will go in
93 db.addInventoryFolder(f1);
94 InventoryFolderBase f1a = db.getUserRootFolder(owner1);
95 Assert.That(f1a, Is.Null);
96 }
97
98 [Test]
99 public void T011_FolderCreate()
100 {
101 InventoryFolderBase f1 = NewFolder(uuid1, zero, owner1, name1);
102 // TODO: this is probably wrong behavior, but is what we have
103 // db.updateInventoryFolder(f1);
104 // InventoryFolderBase f1a = db.getUserRootFolder(owner1);
105 // Assert.That(uuid1, Is.EqualTo(f1a.ID))
106 // Assert.That(name1, Text.Matches(f1a.Name));
107 // Assert.That(db.getUserRootFolder(owner1), Is.Null);
108
109 // succeed with true
110 db.addInventoryFolder(f1);
111 InventoryFolderBase f1a = db.getUserRootFolder(owner1);
112 Assert.That(uuid1, Is.EqualTo(f1a.ID));
113 Assert.That(name1, Text.Matches(f1a.Name));
114 }
115
116 // we now have the following tree
117 // uuid1
118 // +--- uuid2
119 // +--- uuid3
120
121 [Test]
122 public void T012_FolderList()
123 {
124 InventoryFolderBase f2 = NewFolder(uuid3, uuid1, owner1, name3);
125 db.addInventoryFolder(f2);
126
127 Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1));
128
129 Assert.That(db.getInventoryFolders(uuid1).Count, Is.EqualTo(2));
130
131 Assert.That(db.getInventoryFolders(uuid2).Count, Is.EqualTo(0));
132
133 Assert.That(db.getInventoryFolders(uuid3).Count, Is.EqualTo(0));
134
135 Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0));
136
137 }
138
139 [Test]
140 public void T013_FolderHierarchy()
141 {
142 Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0));
143
144 Assert.That(db.getFolderHierarchy(uuid1).Count, Is.EqualTo(2));
145
146 Assert.That(db.getFolderHierarchy(uuid2).Count, Is.EqualTo(0));
147
148 Assert.That(db.getFolderHierarchy(uuid3).Count, Is.EqualTo(0));
149
150 Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0));
151 }
152
153
154 [Test]
155 public void T014_MoveFolder()
156 {
157 InventoryFolderBase f2 = db.getInventoryFolder(uuid2);
158 f2.ParentID = uuid3;
159 db.moveInventoryFolder(f2);
160
161 Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1));
162
163 Assert.That(db.getInventoryFolders(uuid1).Count, Is.EqualTo(1));
164
165 Assert.That(db.getInventoryFolders(uuid2).Count, Is.EqualTo(0));
166
167 Assert.That(db.getInventoryFolders(uuid3).Count, Is.EqualTo(1));
168
169 Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0));
170 }
171
172 [Test]
173 public void T015_FolderHierarchy()
174 {
175 Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0));
176
177 Assert.That(db.getFolderHierarchy(uuid1).Count, Is.EqualTo(2));
178
179 Assert.That(db.getFolderHierarchy(uuid2).Count, Is.EqualTo(0));
180
181 Assert.That(db.getFolderHierarchy(uuid3).Count, Is.EqualTo(1));
182
183 Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0));
184 }
185
186
187
188 private InventoryFolderBase NewFolder(UUID id, UUID parent, UUID owner, string name)
189 {
190 InventoryFolderBase f = new InventoryFolderBase();
191 f.ID = id;
192 f.ParentID = parent;
193 f.Owner = owner;
194 f.Name = name;
195 return f;
196 }
197 } 60 }
198} \ No newline at end of file 61} \ No newline at end of file