aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Tests/BasicInventoryTests.cs
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/Tests/BasicInventoryTests.cs
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/Tests/BasicInventoryTests.cs')
-rw-r--r--OpenSim/Data/Tests/BasicInventoryTests.cs184
1 files changed, 184 insertions, 0 deletions
diff --git a/OpenSim/Data/Tests/BasicInventoryTests.cs b/OpenSim/Data/Tests/BasicInventoryTests.cs
new file mode 100644
index 0000000..47a3393
--- /dev/null
+++ b/OpenSim/Data/Tests/BasicInventoryTests.cs
@@ -0,0 +1,184 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenSim.Framework;
33using OpenSim.Data.Tests;
34using OpenSim.Region.Environment.Scenes;
35using OpenMetaverse;
36
37namespace OpenSim.Data.Tests
38{
39 public class BasicInventoryTest
40 {
41 public IInventoryDataPlugin db;
42 public UUID zero = UUID.Zero;
43 public UUID uuid1;
44 public UUID uuid2;
45 public UUID uuid3;
46 public UUID owner1;
47 public UUID owner2;
48 public UUID owner3;
49 public string name1;
50 public string name2;
51 public string name3;
52
53 public void SuperInit()
54 {
55 uuid1 = UUID.Random();
56 uuid2 = UUID.Random();
57 uuid3 = UUID.Random();
58 owner1 = UUID.Random();
59 owner2 = UUID.Random();
60 owner3 = UUID.Random();
61 name1 = "Root Folder for " + owner1.ToString();
62 name2 = "First Level folder";
63 name3 = "First Level folder 2";
64 }
65
66 [Test]
67 public void T001_LoadEmpty()
68 {
69 Assert.That(db.getInventoryItem(uuid1), Is.Null);
70 Assert.That(db.getUserRootFolder(owner1), Is.Null);
71 }
72
73 // 01x - folder tests
74 [Test]
75 public void T010_FolderNonParent()
76 {
77 InventoryFolderBase f1 = NewFolder(uuid2, uuid1, owner1, name2);
78 // the folder will go in
79 db.addInventoryFolder(f1);
80 InventoryFolderBase f1a = db.getUserRootFolder(owner1);
81 Assert.That(f1a, Is.Null);
82 }
83
84 [Test]
85 public void T011_FolderCreate()
86 {
87 InventoryFolderBase f1 = NewFolder(uuid1, zero, owner1, name1);
88 // TODO: this is probably wrong behavior, but is what we have
89 // db.updateInventoryFolder(f1);
90 // InventoryFolderBase f1a = db.getUserRootFolder(owner1);
91 // Assert.That(uuid1, Is.EqualTo(f1a.ID))
92 // Assert.That(name1, Text.Matches(f1a.Name));
93 // Assert.That(db.getUserRootFolder(owner1), Is.Null);
94
95 // succeed with true
96 db.addInventoryFolder(f1);
97 InventoryFolderBase f1a = db.getUserRootFolder(owner1);
98 Assert.That(uuid1, Is.EqualTo(f1a.ID));
99 Assert.That(name1, Text.Matches(f1a.Name));
100 }
101
102 // we now have the following tree
103 // uuid1
104 // +--- uuid2
105 // +--- uuid3
106
107 [Test]
108 public void T012_FolderList()
109 {
110 InventoryFolderBase f2 = NewFolder(uuid3, uuid1, owner1, name3);
111 db.addInventoryFolder(f2);
112
113 Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1));
114
115 Assert.That(db.getInventoryFolders(uuid1).Count, Is.EqualTo(2));
116
117 Assert.That(db.getInventoryFolders(uuid2).Count, Is.EqualTo(0));
118
119 Assert.That(db.getInventoryFolders(uuid3).Count, Is.EqualTo(0));
120
121 Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0));
122
123 }
124
125 [Test]
126 public void T013_FolderHierarchy()
127 {
128 Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0));
129
130 Assert.That(db.getFolderHierarchy(uuid1).Count, Is.EqualTo(2));
131
132 Assert.That(db.getFolderHierarchy(uuid2).Count, Is.EqualTo(0));
133
134 Assert.That(db.getFolderHierarchy(uuid3).Count, Is.EqualTo(0));
135
136 Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0));
137 }
138
139
140 [Test]
141 public void T014_MoveFolder()
142 {
143 InventoryFolderBase f2 = db.getInventoryFolder(uuid2);
144 f2.ParentID = uuid3;
145 db.moveInventoryFolder(f2);
146
147 Assert.That(db.getInventoryFolders(zero).Count, Is.EqualTo(1));
148
149 Assert.That(db.getInventoryFolders(uuid1).Count, Is.EqualTo(1));
150
151 Assert.That(db.getInventoryFolders(uuid2).Count, Is.EqualTo(0));
152
153 Assert.That(db.getInventoryFolders(uuid3).Count, Is.EqualTo(1));
154
155 Assert.That(db.getInventoryFolders(UUID.Random()).Count, Is.EqualTo(0));
156 }
157
158 [Test]
159 public void T015_FolderHierarchy()
160 {
161 Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0));
162
163 Assert.That(db.getFolderHierarchy(uuid1).Count, Is.EqualTo(2));
164
165 Assert.That(db.getFolderHierarchy(uuid2).Count, Is.EqualTo(0));
166
167 Assert.That(db.getFolderHierarchy(uuid3).Count, Is.EqualTo(1));
168
169 Assert.That(db.getFolderHierarchy(UUID.Random()).Count, Is.EqualTo(0));
170 }
171
172
173
174 private InventoryFolderBase NewFolder(UUID id, UUID parent, UUID owner, string name)
175 {
176 InventoryFolderBase f = new InventoryFolderBase();
177 f.ID = id;
178 f.ParentID = parent;
179 f.Owner = owner;
180 f.Name = name;
181 return f;
182 }
183 }
184} \ No newline at end of file