diff options
author | Melanie | 2010-05-26 17:19:02 +0100 |
---|---|---|
committer | Melanie | 2010-05-26 17:19:02 +0100 |
commit | 97501495eb2f54912b862d9dd544ca467e8b9d1e (patch) | |
tree | 3fed12f5c6bcc514368b40b16a0a0f165ab9aac1 /OpenSim/Data/Tests/RegionTests.cs | |
parent | Merge branch 'master' into careminster-presence-refactor (diff) | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC_OLD-97501495eb2f54912b862d9dd544ca467e8b9d1e.zip opensim-SC_OLD-97501495eb2f54912b862d9dd544ca467e8b9d1e.tar.gz opensim-SC_OLD-97501495eb2f54912b862d9dd544ca467e8b9d1e.tar.bz2 opensim-SC_OLD-97501495eb2f54912b862d9dd544ca467e8b9d1e.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Data/Tests/RegionTests.cs')
-rw-r--r-- | OpenSim/Data/Tests/RegionTests.cs | 1134 |
1 files changed, 1134 insertions, 0 deletions
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs new file mode 100644 index 0000000..1f654d3 --- /dev/null +++ b/OpenSim/Data/Tests/RegionTests.cs | |||
@@ -0,0 +1,1134 @@ | |||
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 OpenSimulator 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Drawing; | ||
31 | using System.Text; | ||
32 | using log4net.Config; | ||
33 | using NUnit.Framework; | ||
34 | using NUnit.Framework.SyntaxHelpers; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using log4net; | ||
40 | using System.Reflection; | ||
41 | using System.Data.Common; | ||
42 | |||
43 | #if !NUNIT25 | ||
44 | using NUnit.Framework.SyntaxHelpers; | ||
45 | #endif | ||
46 | |||
47 | // DBMS-specific: | ||
48 | using MySql.Data.MySqlClient; | ||
49 | using OpenSim.Data.MySQL; | ||
50 | |||
51 | using System.Data.SqlClient; | ||
52 | using OpenSim.Data.MSSQL; | ||
53 | |||
54 | using Mono.Data.Sqlite; | ||
55 | using OpenSim.Data.SQLite; | ||
56 | |||
57 | namespace OpenSim.Data.Tests | ||
58 | { | ||
59 | #if NUNIT25 | ||
60 | |||
61 | [TestFixture(typeof(SqliteConnection), typeof(SQLiteRegionData), Description = "Region store tests (SQLite)")] | ||
62 | [TestFixture(typeof(MySqlConnection), typeof(MySqlRegionData), Description = "Region store tests (MySQL)")] | ||
63 | [TestFixture(typeof(SqlConnection), typeof(MSSQLRegionData), Description = "Region store tests (MS SQL Server)")] | ||
64 | |||
65 | #else | ||
66 | |||
67 | [TestFixture(Description = "Region store tests (SQLite)")] | ||
68 | public class SQLiteRegionTests : RegionTests<SqliteConnection, SQLiteRegionData> | ||
69 | { | ||
70 | } | ||
71 | |||
72 | [TestFixture(Description = "Region store tests (MySQL)")] | ||
73 | public class MySqlRegionTests : RegionTests<MySqlConnection, MySQLDataStore> | ||
74 | { | ||
75 | } | ||
76 | |||
77 | [TestFixture(Description = "Region store tests (MS SQL Server)")] | ||
78 | public class MSSQLRegionTests : RegionTests<SqlConnection, MSSQLRegionDataStore> | ||
79 | { | ||
80 | } | ||
81 | |||
82 | #endif | ||
83 | |||
84 | public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore> | ||
85 | where TConn : DbConnection, new() | ||
86 | where TRegStore : class, IRegionDataStore, new() | ||
87 | { | ||
88 | bool m_rebuildDB; | ||
89 | |||
90 | public IRegionDataStore db; | ||
91 | public UUID zero = UUID.Zero; | ||
92 | public UUID region1 = UUID.Random(); | ||
93 | public UUID region2 = UUID.Random(); | ||
94 | public UUID region3 = UUID.Random(); | ||
95 | public UUID region4 = UUID.Random(); | ||
96 | public UUID prim1 = UUID.Random(); | ||
97 | public UUID prim2 = UUID.Random(); | ||
98 | public UUID prim3 = UUID.Random(); | ||
99 | public UUID prim4 = UUID.Random(); | ||
100 | public UUID prim5 = UUID.Random(); | ||
101 | public UUID prim6 = UUID.Random(); | ||
102 | public UUID item1 = UUID.Random(); | ||
103 | public UUID item2 = UUID.Random(); | ||
104 | public UUID item3 = UUID.Random(); | ||
105 | |||
106 | public static Random random = new Random(); | ||
107 | |||
108 | public string itemname1 = "item1"; | ||
109 | |||
110 | public uint localID = 1; | ||
111 | |||
112 | public double height1 = 20; | ||
113 | public double height2 = 100; | ||
114 | |||
115 | public RegionTests(string conn, bool rebuild) | ||
116 | : base(conn) | ||
117 | { | ||
118 | m_rebuildDB = rebuild; | ||
119 | } | ||
120 | |||
121 | public RegionTests() : this("", true) { } | ||
122 | public RegionTests(string conn) : this(conn, true) {} | ||
123 | public RegionTests(bool rebuild): this("", rebuild) {} | ||
124 | |||
125 | |||
126 | protected override void InitService(object service) | ||
127 | { | ||
128 | ClearDB(); | ||
129 | db = (IRegionDataStore)service; | ||
130 | db.Initialise(m_connStr); | ||
131 | } | ||
132 | |||
133 | private void ClearDB() | ||
134 | { | ||
135 | string[] reg_tables = new string[] { | ||
136 | "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings" | ||
137 | }; | ||
138 | if (m_rebuildDB) | ||
139 | { | ||
140 | DropTables(reg_tables); | ||
141 | ResetMigrations("RegionStore"); | ||
142 | }else | ||
143 | ClearTables(reg_tables); | ||
144 | } | ||
145 | |||
146 | |||
147 | // Test Plan | ||
148 | // Prims | ||
149 | // - empty test - 001 | ||
150 | // - store / retrieve basic prims (most minimal we can make) - 010, 011 | ||
151 | // - store / retrieve parts in a scenegroup 012 | ||
152 | // - store a prim with complete information for consistency check 013 | ||
153 | // - update existing prims, make sure it sticks - 014 | ||
154 | // - tests empty inventory - 020 | ||
155 | // - add inventory items to prims make - 021 | ||
156 | // - retrieves the added item - 022 | ||
157 | // - update inventory items to prims - 023 | ||
158 | // - remove inventory items make sure it sticks - 024 | ||
159 | // - checks if all parameters are persistent - 025 | ||
160 | // - adds many items and see if it is handled correctly - 026 | ||
161 | |||
162 | [Test] | ||
163 | public void T001_LoadEmpty() | ||
164 | { | ||
165 | List<SceneObjectGroup> objs = db.LoadObjects(region1); | ||
166 | List<SceneObjectGroup> objs3 = db.LoadObjects(region3); | ||
167 | List<LandData> land = db.LoadLandObjects(region1); | ||
168 | |||
169 | Assert.That(objs.Count, Is.EqualTo(0), "Assert.That(objs.Count, Is.EqualTo(0))"); | ||
170 | Assert.That(objs3.Count, Is.EqualTo(0), "Assert.That(objs3.Count, Is.EqualTo(0))"); | ||
171 | Assert.That(land.Count, Is.EqualTo(0), "Assert.That(land.Count, Is.EqualTo(0))"); | ||
172 | } | ||
173 | |||
174 | // SOG round trips | ||
175 | // * store objects, make sure they save | ||
176 | // * update | ||
177 | |||
178 | [Test] | ||
179 | public void T010_StoreSimpleObject() | ||
180 | { | ||
181 | SceneObjectGroup sog = NewSOG("object1", prim1, region1); | ||
182 | SceneObjectGroup sog2 = NewSOG("object2", prim2, region1); | ||
183 | |||
184 | // in case the objects don't store | ||
185 | try | ||
186 | { | ||
187 | db.StoreObject(sog, region1); | ||
188 | } | ||
189 | catch (Exception e) | ||
190 | { | ||
191 | m_log.Error(e.ToString()); | ||
192 | Assert.Fail(); | ||
193 | } | ||
194 | |||
195 | try | ||
196 | { | ||
197 | db.StoreObject(sog2, region1); | ||
198 | } | ||
199 | catch (Exception e) | ||
200 | { | ||
201 | m_log.Error(e.ToString()); | ||
202 | Assert.Fail(); | ||
203 | } | ||
204 | |||
205 | // This tests the ADO.NET driver | ||
206 | List<SceneObjectGroup> objs = db.LoadObjects(region1); | ||
207 | |||
208 | Assert.That(objs.Count, Is.EqualTo(2), "Assert.That(objs.Count, Is.EqualTo(2))"); | ||
209 | } | ||
210 | |||
211 | [Test] | ||
212 | public void T011_ObjectNames() | ||
213 | { | ||
214 | List<SceneObjectGroup> objs = db.LoadObjects(region1); | ||
215 | foreach (SceneObjectGroup sog in objs) | ||
216 | { | ||
217 | SceneObjectPart p = sog.RootPart; | ||
218 | Assert.That("", Is.Not.EqualTo(p.Name), "Assert.That(\"\", Is.Not.EqualTo(p.Name))"); | ||
219 | Assert.That(p.Name, Is.EqualTo(p.Description), "Assert.That(p.Name, Is.EqualTo(p.Description))"); | ||
220 | } | ||
221 | } | ||
222 | |||
223 | [Test] | ||
224 | public void T012_SceneParts() | ||
225 | { | ||
226 | UUID tmp0 = UUID.Random(); | ||
227 | UUID tmp1 = UUID.Random(); | ||
228 | UUID tmp2 = UUID.Random(); | ||
229 | UUID tmp3 = UUID.Random(); | ||
230 | UUID newregion = UUID.Random(); | ||
231 | SceneObjectPart p1 = NewSOP("SoP 1",tmp1); | ||
232 | SceneObjectPart p2 = NewSOP("SoP 2",tmp2); | ||
233 | SceneObjectPart p3 = NewSOP("SoP 3",tmp3); | ||
234 | SceneObjectGroup sog = NewSOG("Sop 0", tmp0, newregion); | ||
235 | sog.AddPart(p1); | ||
236 | sog.AddPart(p2); | ||
237 | sog.AddPart(p3); | ||
238 | |||
239 | SceneObjectPart[] parts = sog.GetParts(); | ||
240 | Assert.That(parts.Length,Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))"); | ||
241 | |||
242 | db.StoreObject(sog, newregion); | ||
243 | List<SceneObjectGroup> sogs = db.LoadObjects(newregion); | ||
244 | Assert.That(sogs.Count,Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))"); | ||
245 | SceneObjectGroup newsog = sogs[0]; | ||
246 | |||
247 | SceneObjectPart[] newparts = newsog.GetParts(); | ||
248 | Assert.That(newparts.Length,Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))"); | ||
249 | |||
250 | Assert.That(newsog.HasChildPrim(tmp0), "Assert.That(newsog.HasChildPrim(tmp0))"); | ||
251 | Assert.That(newsog.HasChildPrim(tmp1), "Assert.That(newsog.HasChildPrim(tmp1))"); | ||
252 | Assert.That(newsog.HasChildPrim(tmp2), "Assert.That(newsog.HasChildPrim(tmp2))"); | ||
253 | Assert.That(newsog.HasChildPrim(tmp3), "Assert.That(newsog.HasChildPrim(tmp3))"); | ||
254 | } | ||
255 | |||
256 | [Test] | ||
257 | public void T013_DatabasePersistency() | ||
258 | { | ||
259 | // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data | ||
260 | // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored | ||
261 | // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently. | ||
262 | UUID creator,uuid = new UUID(); | ||
263 | creator = UUID.Random(); | ||
264 | uint iserial = (uint)random.Next(); | ||
265 | TaskInventoryDictionary dic = new TaskInventoryDictionary(); | ||
266 | uint objf = (uint) random.Next(); | ||
267 | uuid = prim4; | ||
268 | uint localid = localID+1; | ||
269 | localID = localID + 1; | ||
270 | string name = "Adam West"; | ||
271 | byte material = (byte) random.Next(127); | ||
272 | ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next(); | ||
273 | int pin = random.Next(); | ||
274 | Byte[] partsys = new byte[8]; | ||
275 | Byte[] textani = new byte[8]; | ||
276 | random.NextBytes(textani); | ||
277 | random.NextBytes(partsys); | ||
278 | DateTime expires = new DateTime(2008, 12, 20); | ||
279 | DateTime rezzed = new DateTime(2009, 07, 15); | ||
280 | Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next()); | ||
281 | Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next()); | ||
282 | Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next()); | ||
283 | Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next()); | ||
284 | Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next()); | ||
285 | Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next()); | ||
286 | string description = name; | ||
287 | Color color = Color.FromArgb(255, 165, 50, 100); | ||
288 | string text = "All Your Base Are Belong to Us"; | ||
289 | string sitname = "SitName"; | ||
290 | string touchname = "TouchName"; | ||
291 | int linknum = random.Next(); | ||
292 | byte clickaction = (byte) random.Next(127); | ||
293 | PrimitiveBaseShape pbshap = new PrimitiveBaseShape(); | ||
294 | pbshap = PrimitiveBaseShape.Default; | ||
295 | pbshap.PathBegin = ushort.MaxValue; | ||
296 | pbshap.PathEnd = ushort.MaxValue; | ||
297 | pbshap.ProfileBegin = ushort.MaxValue; | ||
298 | pbshap.ProfileEnd = ushort.MaxValue; | ||
299 | pbshap.ProfileHollow = ushort.MaxValue; | ||
300 | Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); | ||
301 | byte updatef = (byte) random.Next(127); | ||
302 | |||
303 | RegionInfo regionInfo = new RegionInfo(); | ||
304 | regionInfo.RegionID = region3; | ||
305 | regionInfo.RegionLocX = 0; | ||
306 | regionInfo.RegionLocY = 0; | ||
307 | |||
308 | // Scene scene = new Scene(regionInfo); | ||
309 | |||
310 | SceneObjectPart sop = new SceneObjectPart(); | ||
311 | sop.RegionHandle = regionh; | ||
312 | sop.UUID = uuid; | ||
313 | sop.LocalId = localid; | ||
314 | sop.Shape = pbshap; | ||
315 | sop.GroupPosition = groupos; | ||
316 | sop.RotationOffset = rotoff; | ||
317 | sop.CreatorID = creator; | ||
318 | sop.InventorySerial = iserial; | ||
319 | sop.TaskInventory = dic; | ||
320 | sop.ObjectFlags = objf; | ||
321 | sop.Name = name; | ||
322 | sop.Material = material; | ||
323 | sop.ScriptAccessPin = pin; | ||
324 | sop.TextureAnimation = textani; | ||
325 | sop.ParticleSystem = partsys; | ||
326 | sop.Expires = expires; | ||
327 | sop.Rezzed = rezzed; | ||
328 | sop.OffsetPosition = offset; | ||
329 | sop.Velocity = velocity; | ||
330 | sop.AngularVelocity = angvelo; | ||
331 | sop.Acceleration = accel; | ||
332 | sop.Description = description; | ||
333 | sop.Color = color; | ||
334 | sop.Text = text; | ||
335 | sop.SitName = sitname; | ||
336 | sop.TouchName = touchname; | ||
337 | sop.LinkNum = linknum; | ||
338 | sop.ClickAction = clickaction; | ||
339 | sop.Scale = scale; | ||
340 | sop.UpdateFlag = updatef; | ||
341 | |||
342 | //Tests if local part accepted the parameters: | ||
343 | Assert.That(regionh,Is.EqualTo(sop.RegionHandle), "Assert.That(regionh,Is.EqualTo(sop.RegionHandle))"); | ||
344 | Assert.That(localid,Is.EqualTo(sop.LocalId), "Assert.That(localid,Is.EqualTo(sop.LocalId))"); | ||
345 | Assert.That(groupos,Is.EqualTo(sop.GroupPosition), "Assert.That(groupos,Is.EqualTo(sop.GroupPosition))"); | ||
346 | Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))"); | ||
347 | Assert.That(rotoff,Is.EqualTo(sop.RotationOffset), "Assert.That(rotoff,Is.EqualTo(sop.RotationOffset))"); | ||
348 | Assert.That(uuid,Is.EqualTo(sop.UUID), "Assert.That(uuid,Is.EqualTo(sop.UUID))"); | ||
349 | Assert.That(creator,Is.EqualTo(sop.CreatorID), "Assert.That(creator,Is.EqualTo(sop.CreatorID))"); | ||
350 | // Modified in-class | ||
351 | // Assert.That(iserial,Is.EqualTo(sop.InventorySerial), "Assert.That(iserial,Is.EqualTo(sop.InventorySerial))"); | ||
352 | Assert.That(dic,Is.EqualTo(sop.TaskInventory), "Assert.That(dic,Is.EqualTo(sop.TaskInventory))"); | ||
353 | Assert.That(objf,Is.EqualTo(sop.ObjectFlags), "Assert.That(objf,Is.EqualTo(sop.ObjectFlags))"); | ||
354 | Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))"); | ||
355 | Assert.That(material,Is.EqualTo(sop.Material), "Assert.That(material,Is.EqualTo(sop.Material))"); | ||
356 | Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin))"); | ||
357 | Assert.That(textani,Is.EqualTo(sop.TextureAnimation), "Assert.That(textani,Is.EqualTo(sop.TextureAnimation))"); | ||
358 | Assert.That(partsys,Is.EqualTo(sop.ParticleSystem), "Assert.That(partsys,Is.EqualTo(sop.ParticleSystem))"); | ||
359 | Assert.That(expires,Is.EqualTo(sop.Expires), "Assert.That(expires,Is.EqualTo(sop.Expires))"); | ||
360 | Assert.That(rezzed,Is.EqualTo(sop.Rezzed), "Assert.That(rezzed,Is.EqualTo(sop.Rezzed))"); | ||
361 | Assert.That(offset,Is.EqualTo(sop.OffsetPosition), "Assert.That(offset,Is.EqualTo(sop.OffsetPosition))"); | ||
362 | Assert.That(velocity,Is.EqualTo(sop.Velocity), "Assert.That(velocity,Is.EqualTo(sop.Velocity))"); | ||
363 | Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity))"); | ||
364 | Assert.That(accel,Is.EqualTo(sop.Acceleration), "Assert.That(accel,Is.EqualTo(sop.Acceleration))"); | ||
365 | Assert.That(description,Is.EqualTo(sop.Description), "Assert.That(description,Is.EqualTo(sop.Description))"); | ||
366 | Assert.That(color,Is.EqualTo(sop.Color), "Assert.That(color,Is.EqualTo(sop.Color))"); | ||
367 | Assert.That(text,Is.EqualTo(sop.Text), "Assert.That(text,Is.EqualTo(sop.Text))"); | ||
368 | Assert.That(sitname,Is.EqualTo(sop.SitName), "Assert.That(sitname,Is.EqualTo(sop.SitName))"); | ||
369 | Assert.That(touchname,Is.EqualTo(sop.TouchName), "Assert.That(touchname,Is.EqualTo(sop.TouchName))"); | ||
370 | Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))"); | ||
371 | Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))"); | ||
372 | Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))"); | ||
373 | Assert.That(updatef,Is.EqualTo(sop.UpdateFlag), "Assert.That(updatef,Is.EqualTo(sop.UpdateFlag))"); | ||
374 | |||
375 | // This is necessary or object will not be inserted in DB | ||
376 | sop.ObjectFlags = 0; | ||
377 | |||
378 | SceneObjectGroup sog = new SceneObjectGroup(sop); | ||
379 | |||
380 | // Inserts group in DB | ||
381 | db.StoreObject(sog,region3); | ||
382 | List<SceneObjectGroup> sogs = db.LoadObjects(region3); | ||
383 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); | ||
384 | // Makes sure there are no double insertions: | ||
385 | db.StoreObject(sog,region3); | ||
386 | sogs = db.LoadObjects(region3); | ||
387 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); | ||
388 | |||
389 | |||
390 | // Tests if the parameters were inserted correctly | ||
391 | SceneObjectPart p = sogs[0].RootPart; | ||
392 | Assert.That(regionh,Is.EqualTo(p.RegionHandle), "Assert.That(regionh,Is.EqualTo(p.RegionHandle))"); | ||
393 | //Assert.That(localid,Is.EqualTo(p.LocalId), "Assert.That(localid,Is.EqualTo(p.LocalId))"); | ||
394 | Assert.That(groupos,Is.EqualTo(p.GroupPosition), "Assert.That(groupos,Is.EqualTo(p.GroupPosition))"); | ||
395 | Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); | ||
396 | Assert.That(rotoff,Is.EqualTo(p.RotationOffset), "Assert.That(rotoff,Is.EqualTo(p.RotationOffset))"); | ||
397 | Assert.That(uuid,Is.EqualTo(p.UUID), "Assert.That(uuid,Is.EqualTo(p.UUID))"); | ||
398 | Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))"); | ||
399 | //Assert.That(iserial,Is.EqualTo(p.InventorySerial), "Assert.That(iserial,Is.EqualTo(p.InventorySerial))"); | ||
400 | Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))"); | ||
401 | //Assert.That(objf,Is.EqualTo(p.ObjectFlags), "Assert.That(objf,Is.EqualTo(p.ObjectFlags))"); | ||
402 | Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); | ||
403 | Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))"); | ||
404 | Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))"); | ||
405 | Assert.That(textani,Is.EqualTo(p.TextureAnimation), "Assert.That(textani,Is.EqualTo(p.TextureAnimation))"); | ||
406 | Assert.That(partsys,Is.EqualTo(p.ParticleSystem), "Assert.That(partsys,Is.EqualTo(p.ParticleSystem))"); | ||
407 | //Assert.That(expires,Is.EqualTo(p.Expires), "Assert.That(expires,Is.EqualTo(p.Expires))"); | ||
408 | //Assert.That(rezzed,Is.EqualTo(p.Rezzed), "Assert.That(rezzed,Is.EqualTo(p.Rezzed))"); | ||
409 | Assert.That(offset,Is.EqualTo(p.OffsetPosition), "Assert.That(offset,Is.EqualTo(p.OffsetPosition))"); | ||
410 | Assert.That(velocity,Is.EqualTo(p.Velocity), "Assert.That(velocity,Is.EqualTo(p.Velocity))"); | ||
411 | Assert.That(angvelo,Is.EqualTo(p.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))"); | ||
412 | Assert.That(accel,Is.EqualTo(p.Acceleration), "Assert.That(accel,Is.EqualTo(p.Acceleration))"); | ||
413 | Assert.That(description,Is.EqualTo(p.Description), "Assert.That(description,Is.EqualTo(p.Description))"); | ||
414 | Assert.That(color,Is.EqualTo(p.Color), "Assert.That(color,Is.EqualTo(p.Color))"); | ||
415 | Assert.That(text,Is.EqualTo(p.Text), "Assert.That(text,Is.EqualTo(p.Text))"); | ||
416 | Assert.That(sitname,Is.EqualTo(p.SitName), "Assert.That(sitname,Is.EqualTo(p.SitName))"); | ||
417 | Assert.That(touchname,Is.EqualTo(p.TouchName), "Assert.That(touchname,Is.EqualTo(p.TouchName))"); | ||
418 | //Assert.That(linknum,Is.EqualTo(p.LinkNum), "Assert.That(linknum,Is.EqualTo(p.LinkNum))"); | ||
419 | Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); | ||
420 | Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); | ||
421 | |||
422 | //Assert.That(updatef,Is.EqualTo(p.UpdateFlag), "Assert.That(updatef,Is.EqualTo(p.UpdateFlag))"); | ||
423 | |||
424 | Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin), "Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin))"); | ||
425 | Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd), "Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd))"); | ||
426 | Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin), "Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin))"); | ||
427 | Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd), "Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd))"); | ||
428 | Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow), "Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow))"); | ||
429 | } | ||
430 | |||
431 | [Test] | ||
432 | public void T014_UpdateObject() | ||
433 | { | ||
434 | string text1 = "object1 text"; | ||
435 | SceneObjectGroup sog = FindSOG("object1", region1); | ||
436 | sog.RootPart.Text = text1; | ||
437 | db.StoreObject(sog, region1); | ||
438 | |||
439 | sog = FindSOG("object1", region1); | ||
440 | Assert.That(text1, Is.EqualTo(sog.RootPart.Text), "Assert.That(text1, Is.EqualTo(sog.RootPart.Text))"); | ||
441 | |||
442 | // Creates random values | ||
443 | UUID creator = new UUID(); | ||
444 | creator = UUID.Random(); | ||
445 | TaskInventoryDictionary dic = new TaskInventoryDictionary(); | ||
446 | localID = localID + 1; | ||
447 | string name = "West Adam"; | ||
448 | byte material = (byte) random.Next(127); | ||
449 | ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next(); | ||
450 | int pin = random.Next(); | ||
451 | Byte[] partsys = new byte[8]; | ||
452 | Byte[] textani = new byte[8]; | ||
453 | random.NextBytes(textani); | ||
454 | random.NextBytes(partsys); | ||
455 | DateTime expires = new DateTime(2010, 12, 20); | ||
456 | DateTime rezzed = new DateTime(2005, 07, 15); | ||
457 | Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next()); | ||
458 | Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next()); | ||
459 | Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next()); | ||
460 | Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next()); | ||
461 | Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next()); | ||
462 | Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next()); | ||
463 | string description = name; | ||
464 | Color color = Color.FromArgb(255, 255, 255, 0); | ||
465 | string text = "What You Say?{]\vz~"; | ||
466 | string sitname = RandomName(); | ||
467 | string touchname = RandomName(); | ||
468 | int linknum = random.Next(); | ||
469 | byte clickaction = (byte) random.Next(127); | ||
470 | PrimitiveBaseShape pbshap = new PrimitiveBaseShape(); | ||
471 | pbshap = PrimitiveBaseShape.Default; | ||
472 | Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); | ||
473 | byte updatef = (byte) random.Next(127); | ||
474 | |||
475 | // Updates the region with new values | ||
476 | SceneObjectGroup sog2 = FindSOG("Adam West", region3); | ||
477 | Assert.That(sog2,Is.Not.Null); | ||
478 | sog2.RootPart.RegionHandle = regionh; | ||
479 | sog2.RootPart.Shape = pbshap; | ||
480 | sog2.RootPart.GroupPosition = groupos; | ||
481 | sog2.RootPart.RotationOffset = rotoff; | ||
482 | sog2.RootPart.CreatorID = creator; | ||
483 | sog2.RootPart.TaskInventory = dic; | ||
484 | sog2.RootPart.Name = name; | ||
485 | sog2.RootPart.Material = material; | ||
486 | sog2.RootPart.ScriptAccessPin = pin; | ||
487 | sog2.RootPart.TextureAnimation = textani; | ||
488 | sog2.RootPart.ParticleSystem = partsys; | ||
489 | sog2.RootPart.Expires = expires; | ||
490 | sog2.RootPart.Rezzed = rezzed; | ||
491 | sog2.RootPart.OffsetPosition = offset; | ||
492 | sog2.RootPart.Velocity = velocity; | ||
493 | sog2.RootPart.AngularVelocity = angvelo; | ||
494 | sog2.RootPart.Acceleration = accel; | ||
495 | sog2.RootPart.Description = description; | ||
496 | sog2.RootPart.Color = color; | ||
497 | sog2.RootPart.Text = text; | ||
498 | sog2.RootPart.SitName = sitname; | ||
499 | sog2.RootPart.TouchName = touchname; | ||
500 | sog2.RootPart.LinkNum = linknum; | ||
501 | sog2.RootPart.ClickAction = clickaction; | ||
502 | sog2.RootPart.Scale = scale; | ||
503 | sog2.RootPart.UpdateFlag = updatef; | ||
504 | |||
505 | db.StoreObject(sog2, region3); | ||
506 | List<SceneObjectGroup> sogs = db.LoadObjects(region3); | ||
507 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); | ||
508 | |||
509 | SceneObjectGroup retsog = FindSOG("West Adam", region3); | ||
510 | Assert.That(retsog,Is.Not.Null); | ||
511 | SceneObjectPart p = retsog.RootPart; | ||
512 | Assert.That(regionh,Is.EqualTo(p.RegionHandle), "Assert.That(regionh,Is.EqualTo(p.RegionHandle))"); | ||
513 | Assert.That(groupos,Is.EqualTo(p.GroupPosition), "Assert.That(groupos,Is.EqualTo(p.GroupPosition))"); | ||
514 | Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); | ||
515 | Assert.That(rotoff,Is.EqualTo(p.RotationOffset), "Assert.That(rotoff,Is.EqualTo(p.RotationOffset))"); | ||
516 | Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))"); | ||
517 | Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))"); | ||
518 | Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); | ||
519 | Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))"); | ||
520 | Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))"); | ||
521 | Assert.That(textani,Is.EqualTo(p.TextureAnimation), "Assert.That(textani,Is.EqualTo(p.TextureAnimation))"); | ||
522 | Assert.That(partsys,Is.EqualTo(p.ParticleSystem), "Assert.That(partsys,Is.EqualTo(p.ParticleSystem))"); | ||
523 | Assert.That(offset,Is.EqualTo(p.OffsetPosition), "Assert.That(offset,Is.EqualTo(p.OffsetPosition))"); | ||
524 | Assert.That(velocity,Is.EqualTo(p.Velocity), "Assert.That(velocity,Is.EqualTo(p.Velocity))"); | ||
525 | Assert.That(angvelo,Is.EqualTo(p.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))"); | ||
526 | Assert.That(accel,Is.EqualTo(p.Acceleration), "Assert.That(accel,Is.EqualTo(p.Acceleration))"); | ||
527 | Assert.That(description,Is.EqualTo(p.Description), "Assert.That(description,Is.EqualTo(p.Description))"); | ||
528 | Assert.That(color,Is.EqualTo(p.Color), "Assert.That(color,Is.EqualTo(p.Color))"); | ||
529 | Assert.That(text,Is.EqualTo(p.Text), "Assert.That(text,Is.EqualTo(p.Text))"); | ||
530 | Assert.That(sitname,Is.EqualTo(p.SitName), "Assert.That(sitname,Is.EqualTo(p.SitName))"); | ||
531 | Assert.That(touchname,Is.EqualTo(p.TouchName), "Assert.That(touchname,Is.EqualTo(p.TouchName))"); | ||
532 | Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); | ||
533 | Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); | ||
534 | } | ||
535 | |||
536 | [Test] | ||
537 | public void T015_LargeSceneObjects() | ||
538 | { | ||
539 | UUID id = UUID.Random(); | ||
540 | Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>(); | ||
541 | SceneObjectGroup sog = NewSOG("Test SOG", id, region4); | ||
542 | mydic.Add(sog.RootPart.UUID,sog.RootPart); | ||
543 | for (int i=0;i<30;i++) | ||
544 | { | ||
545 | UUID tmp = UUID.Random(); | ||
546 | SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp); | ||
547 | Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next()); | ||
548 | Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next()); | ||
549 | Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next()); | ||
550 | Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next()); | ||
551 | Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next()); | ||
552 | Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next()); | ||
553 | |||
554 | sop.GroupPosition = groupos; | ||
555 | sop.RotationOffset = rotoff; | ||
556 | sop.OffsetPosition = offset; | ||
557 | sop.Velocity = velocity; | ||
558 | sop.AngularVelocity = angvelo; | ||
559 | sop.Acceleration = accel; | ||
560 | |||
561 | mydic.Add(tmp,sop); | ||
562 | sog.AddPart(sop); | ||
563 | db.StoreObject(sog, region4); | ||
564 | } | ||
565 | |||
566 | SceneObjectGroup retsog = FindSOG("Test SOG", region4); | ||
567 | SceneObjectPart[] parts = retsog.GetParts(); | ||
568 | for (int i=0;i<30;i++) | ||
569 | { | ||
570 | SceneObjectPart cursop = mydic[parts[i].UUID]; | ||
571 | Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition), "Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition))"); | ||
572 | Assert.That(cursop.RotationOffset,Is.EqualTo(parts[i].RotationOffset), "Assert.That(cursop.RotationOffset,Is.EqualTo(parts[i].RotationOffset))"); | ||
573 | Assert.That(cursop.OffsetPosition,Is.EqualTo(parts[i].OffsetPosition), "Assert.That(cursop.OffsetPosition,Is.EqualTo(parts[i].OffsetPosition))"); | ||
574 | Assert.That(cursop.Velocity,Is.EqualTo(parts[i].Velocity), "Assert.That(cursop.Velocity,Is.EqualTo(parts[i].Velocity))"); | ||
575 | Assert.That(cursop.AngularVelocity,Is.EqualTo(parts[i].AngularVelocity), "Assert.That(cursop.AngularVelocity,Is.EqualTo(parts[i].AngularVelocity))"); | ||
576 | Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration), "Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration))"); | ||
577 | } | ||
578 | } | ||
579 | |||
580 | //[Test] | ||
581 | public void T016_RandomSogWithSceneParts() | ||
582 | { | ||
583 | PropertyScrambler<SceneObjectPart> scrambler = | ||
584 | new PropertyScrambler<SceneObjectPart>() | ||
585 | .DontScramble(x => x.UUID); | ||
586 | UUID tmpSog = UUID.Random(); | ||
587 | UUID tmp1 = UUID.Random(); | ||
588 | UUID tmp2 = UUID.Random(); | ||
589 | UUID tmp3 = UUID.Random(); | ||
590 | UUID newregion = UUID.Random(); | ||
591 | SceneObjectPart p1 = new SceneObjectPart(); | ||
592 | SceneObjectPart p2 = new SceneObjectPart(); | ||
593 | SceneObjectPart p3 = new SceneObjectPart(); | ||
594 | p1.Shape = PrimitiveBaseShape.Default; | ||
595 | p2.Shape = PrimitiveBaseShape.Default; | ||
596 | p3.Shape = PrimitiveBaseShape.Default; | ||
597 | p1.UUID = tmp1; | ||
598 | p2.UUID = tmp2; | ||
599 | p3.UUID = tmp3; | ||
600 | scrambler.Scramble(p1); | ||
601 | scrambler.Scramble(p2); | ||
602 | scrambler.Scramble(p3); | ||
603 | |||
604 | SceneObjectGroup sog = NewSOG("Sop 0", tmpSog, newregion); | ||
605 | PropertyScrambler<SceneObjectGroup> sogScrambler = | ||
606 | new PropertyScrambler<SceneObjectGroup>() | ||
607 | .DontScramble(x => x.UUID); | ||
608 | sogScrambler.Scramble(sog); | ||
609 | sog.UUID = tmpSog; | ||
610 | sog.AddPart(p1); | ||
611 | sog.AddPart(p2); | ||
612 | sog.AddPart(p3); | ||
613 | |||
614 | SceneObjectPart[] parts = sog.GetParts(); | ||
615 | Assert.That(parts.Length, Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))"); | ||
616 | |||
617 | db.StoreObject(sog, newregion); | ||
618 | List<SceneObjectGroup> sogs = db.LoadObjects(newregion); | ||
619 | Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))"); | ||
620 | SceneObjectGroup newsog = sogs[0]; | ||
621 | |||
622 | SceneObjectPart[] newparts = newsog.GetParts(); | ||
623 | Assert.That(newparts.Length, Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))"); | ||
624 | |||
625 | Assert.That(newsog, Constraints.PropertyCompareConstraint(sog) | ||
626 | .IgnoreProperty(x=>x.LocalId) | ||
627 | .IgnoreProperty(x=>x.HasGroupChanged) | ||
628 | .IgnoreProperty(x=>x.IsSelected) | ||
629 | .IgnoreProperty(x=>x.RegionHandle) | ||
630 | .IgnoreProperty(x=>x.RegionUUID) | ||
631 | .IgnoreProperty(x=>x.Scene) | ||
632 | .IgnoreProperty(x=>x.Children) | ||
633 | .IgnoreProperty(x=>x.PassCollision) | ||
634 | .IgnoreProperty(x=>x.RootPart)); | ||
635 | } | ||
636 | |||
637 | |||
638 | private SceneObjectGroup GetMySOG(string name) | ||
639 | { | ||
640 | SceneObjectGroup sog = FindSOG(name, region1); | ||
641 | if (sog == null) | ||
642 | { | ||
643 | sog = NewSOG(name, prim1, region1); | ||
644 | db.StoreObject(sog, region1); | ||
645 | } | ||
646 | return sog; | ||
647 | } | ||
648 | |||
649 | |||
650 | // NOTE: it is a bad practice to rely on some of the previous tests having been run before. | ||
651 | // If the tests are run manually, one at a time, each starts with full class init (DB cleared). | ||
652 | // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order. | ||
653 | // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*! | ||
654 | |||
655 | [Test] | ||
656 | public void T020_PrimInventoryEmpty() | ||
657 | { | ||
658 | SceneObjectGroup sog = GetMySOG("object1"); | ||
659 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | ||
660 | Assert.That(t, Is.Null); | ||
661 | } | ||
662 | |||
663 | // TODO: Is there any point to call StorePrimInventory on a list, rather than on the prim itself? | ||
664 | |||
665 | private void StoreInventory(SceneObjectGroup sog) | ||
666 | { | ||
667 | List<TaskInventoryItem> list = new List<TaskInventoryItem>(); | ||
668 | // TODO: seriously??? this is the way we need to loop to get this? | ||
669 | foreach (UUID uuid in sog.RootPart.Inventory.GetInventoryList()) | ||
670 | { | ||
671 | list.Add(sog.GetInventoryItem(sog.RootPart.LocalId, uuid)); | ||
672 | } | ||
673 | |||
674 | db.StorePrimInventory(sog.RootPart.UUID, list); | ||
675 | } | ||
676 | |||
677 | |||
678 | [Test] | ||
679 | public void T021_PrimInventoryBasic() | ||
680 | { | ||
681 | SceneObjectGroup sog = GetMySOG("object1"); | ||
682 | InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero); | ||
683 | |||
684 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); | ||
685 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | ||
686 | Assert.That(t.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); | ||
687 | |||
688 | StoreInventory(sog); | ||
689 | |||
690 | SceneObjectGroup sog1 = FindSOG("object1", region1); | ||
691 | Assert.That(sog1, Is.Not.Null); | ||
692 | |||
693 | TaskInventoryItem t1 = sog1.GetInventoryItem(sog1.RootPart.LocalId, item1); | ||
694 | Assert.That(t1, Is.Not.Null); | ||
695 | Assert.That(t1.Name, Is.EqualTo(itemname1), "Assert.That(t.Name, Is.EqualTo(itemname1))"); | ||
696 | |||
697 | // Updating inventory | ||
698 | t1.Name = "My New Name"; | ||
699 | sog1.UpdateInventoryItem(t1); | ||
700 | |||
701 | StoreInventory(sog1); | ||
702 | |||
703 | SceneObjectGroup sog2 = FindSOG("object1", region1); | ||
704 | TaskInventoryItem t2 = sog2.GetInventoryItem(sog2.RootPart.LocalId, item1); | ||
705 | Assert.That(t2.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))"); | ||
706 | |||
707 | // Removing inventory | ||
708 | |||
709 | List<TaskInventoryItem> list = new List<TaskInventoryItem>(); | ||
710 | db.StorePrimInventory(prim1, list); | ||
711 | |||
712 | sog = FindSOG("object1", region1); | ||
713 | t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); | ||
714 | Assert.That(t, Is.Null); | ||
715 | |||
716 | } | ||
717 | |||
718 | |||
719 | [Test] | ||
720 | public void T025_PrimInventoryPersistency() | ||
721 | { | ||
722 | InventoryItemBase i = new InventoryItemBase(); | ||
723 | UUID id = UUID.Random(); | ||
724 | i.ID = id; | ||
725 | UUID folder = UUID.Random(); | ||
726 | i.Folder = folder; | ||
727 | UUID owner = UUID.Random(); | ||
728 | i.Owner = owner; | ||
729 | UUID creator = UUID.Random(); | ||
730 | i.CreatorId = creator.ToString(); | ||
731 | string name = RandomName(); | ||
732 | i.Name = name; | ||
733 | i.Description = name; | ||
734 | UUID assetid = UUID.Random(); | ||
735 | i.AssetID = assetid; | ||
736 | int invtype = random.Next(); | ||
737 | i.InvType = invtype; | ||
738 | uint nextperm = (uint) random.Next(); | ||
739 | i.NextPermissions = nextperm; | ||
740 | uint curperm = (uint) random.Next(); | ||
741 | i.CurrentPermissions = curperm; | ||
742 | uint baseperm = (uint) random.Next(); | ||
743 | i.BasePermissions = baseperm; | ||
744 | uint eoperm = (uint) random.Next(); | ||
745 | i.EveryOnePermissions = eoperm; | ||
746 | int assettype = random.Next(); | ||
747 | i.AssetType = assettype; | ||
748 | UUID groupid = UUID.Random(); | ||
749 | i.GroupID = groupid; | ||
750 | bool groupown = true; | ||
751 | i.GroupOwned = groupown; | ||
752 | int saleprice = random.Next(); | ||
753 | i.SalePrice = saleprice; | ||
754 | byte saletype = (byte) random.Next(127); | ||
755 | i.SaleType = saletype; | ||
756 | uint flags = (uint) random.Next(); | ||
757 | i.Flags = flags; | ||
758 | int creationd = random.Next(); | ||
759 | i.CreationDate = creationd; | ||
760 | |||
761 | SceneObjectGroup sog = GetMySOG("object1"); | ||
762 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, i, zero), Is.True); | ||
763 | TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, id); | ||
764 | |||
765 | Assert.That(t.Name, Is.EqualTo(name), "Assert.That(t.Name, Is.EqualTo(name))"); | ||
766 | Assert.That(t.AssetID,Is.EqualTo(assetid), "Assert.That(t.AssetID,Is.EqualTo(assetid))"); | ||
767 | Assert.That(t.BasePermissions,Is.EqualTo(baseperm), "Assert.That(t.BasePermissions,Is.EqualTo(baseperm))"); | ||
768 | Assert.That(t.CreationDate,Is.EqualTo(creationd), "Assert.That(t.CreationDate,Is.EqualTo(creationd))"); | ||
769 | Assert.That(t.CreatorID,Is.EqualTo(creator), "Assert.That(t.CreatorID,Is.EqualTo(creator))"); | ||
770 | Assert.That(t.Description,Is.EqualTo(name), "Assert.That(t.Description,Is.EqualTo(name))"); | ||
771 | Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm), "Assert.That(t.EveryonePermissions,Is.EqualTo(eoperm))"); | ||
772 | Assert.That(t.Flags,Is.EqualTo(flags), "Assert.That(t.Flags,Is.EqualTo(flags))"); | ||
773 | Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID), "Assert.That(t.GroupID,Is.EqualTo(sog.RootPart.GroupID))"); | ||
774 | // Where is this group permissions?? | ||
775 | // Assert.That(t.GroupPermissions,Is.EqualTo(), "Assert.That(t.GroupPermissions,Is.EqualTo())"); | ||
776 | Assert.That(t.Type,Is.EqualTo(assettype), "Assert.That(t.Type,Is.EqualTo(assettype))"); | ||
777 | Assert.That(t.InvType, Is.EqualTo(invtype), "Assert.That(t.InvType, Is.EqualTo(invtype))"); | ||
778 | Assert.That(t.ItemID, Is.EqualTo(id), "Assert.That(t.ItemID, Is.EqualTo(id))"); | ||
779 | Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID), "Assert.That(t.LastOwnerID, Is.EqualTo(sog.RootPart.LastOwnerID))"); | ||
780 | Assert.That(t.NextPermissions, Is.EqualTo(nextperm), "Assert.That(t.NextPermissions, Is.EqualTo(nextperm))"); | ||
781 | // Ownership changes when you drop an object into an object | ||
782 | // owned by someone else | ||
783 | Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID), "Assert.That(t.OwnerID,Is.EqualTo(sog.RootPart.OwnerID))"); | ||
784 | Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8), "Assert.That(t.CurrentPermissions, Is.EqualTo(curperm | 8))"); | ||
785 | Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID), "Assert.That(t.ParentID,Is.EqualTo(sog.RootPart.FolderID))"); | ||
786 | Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID), "Assert.That(t.ParentPartID,Is.EqualTo(sog.RootPart.UUID))"); | ||
787 | } | ||
788 | |||
789 | [Test] | ||
790 | [ExpectedException(typeof(ArgumentException))] | ||
791 | public void T026_PrimInventoryMany() | ||
792 | { | ||
793 | UUID i1,i2,i3,i4; | ||
794 | i1 = UUID.Random(); | ||
795 | i2 = UUID.Random(); | ||
796 | i3 = UUID.Random(); | ||
797 | i4 = i3; | ||
798 | InventoryItemBase ib1 = NewItem(i1, zero, zero, RandomName(), zero); | ||
799 | InventoryItemBase ib2 = NewItem(i2, zero, zero, RandomName(), zero); | ||
800 | InventoryItemBase ib3 = NewItem(i3, zero, zero, RandomName(), zero); | ||
801 | InventoryItemBase ib4 = NewItem(i4, zero, zero, RandomName(), zero); | ||
802 | |||
803 | SceneObjectGroup sog = FindSOG("object1", region1); | ||
804 | |||
805 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib1, zero), Is.True); | ||
806 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib2, zero), Is.True); | ||
807 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib3, zero), Is.True); | ||
808 | Assert.That(sog.AddInventoryItem(null, sog.RootPart.LocalId, ib4, zero), Is.True); | ||
809 | |||
810 | TaskInventoryItem t1 = sog.GetInventoryItem(sog.RootPart.LocalId, i1); | ||
811 | Assert.That(t1.Name, Is.EqualTo(ib1.Name), "Assert.That(t1.Name, Is.EqualTo(ib1.Name))"); | ||
812 | TaskInventoryItem t2 = sog.GetInventoryItem(sog.RootPart.LocalId, i2); | ||
813 | Assert.That(t2.Name, Is.EqualTo(ib2.Name), "Assert.That(t2.Name, Is.EqualTo(ib2.Name))"); | ||
814 | TaskInventoryItem t3 = sog.GetInventoryItem(sog.RootPart.LocalId, i3); | ||
815 | Assert.That(t3.Name, Is.EqualTo(ib3.Name), "Assert.That(t3.Name, Is.EqualTo(ib3.Name))"); | ||
816 | TaskInventoryItem t4 = sog.GetInventoryItem(sog.RootPart.LocalId, i4); | ||
817 | Assert.That(t4, Is.Null); | ||
818 | } | ||
819 | |||
820 | [Test] | ||
821 | public void T052_RemoveObject() | ||
822 | { | ||
823 | db.RemoveObject(prim1, region1); | ||
824 | SceneObjectGroup sog = FindSOG("object1", region1); | ||
825 | Assert.That(sog, Is.Null); | ||
826 | } | ||
827 | |||
828 | |||
829 | [Test] | ||
830 | public void T100_DefaultRegionInfo() | ||
831 | { | ||
832 | RegionSettings r1 = db.LoadRegionSettings(region1); | ||
833 | Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))"); | ||
834 | |||
835 | RegionSettings r2 = db.LoadRegionSettings(region2); | ||
836 | Assert.That(r2.RegionUUID, Is.EqualTo(region2), "Assert.That(r2.RegionUUID, Is.EqualTo(region2))"); | ||
837 | } | ||
838 | |||
839 | [Test] | ||
840 | public void T101_UpdateRegionInfo() | ||
841 | { | ||
842 | int agentlimit = random.Next(); | ||
843 | double objectbonus = random.Next(); | ||
844 | int maturity = random.Next(); | ||
845 | UUID tertex1 = UUID.Random(); | ||
846 | UUID tertex2 = UUID.Random(); | ||
847 | UUID tertex3 = UUID.Random(); | ||
848 | UUID tertex4 = UUID.Random(); | ||
849 | double elev1nw = random.Next(); | ||
850 | double elev2nw = random.Next(); | ||
851 | double elev1ne = random.Next(); | ||
852 | double elev2ne = random.Next(); | ||
853 | double elev1se = random.Next(); | ||
854 | double elev2se = random.Next(); | ||
855 | double elev1sw = random.Next(); | ||
856 | double elev2sw = random.Next(); | ||
857 | double waterh = random.Next(); | ||
858 | double terrainraise = random.Next(); | ||
859 | double terrainlower = random.Next(); | ||
860 | Vector3 sunvector = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5)); | ||
861 | UUID terimgid = UUID.Random(); | ||
862 | double sunpos = random.Next(); | ||
863 | UUID cov = UUID.Random(); | ||
864 | |||
865 | RegionSettings r1 = db.LoadRegionSettings(region1); | ||
866 | r1.BlockTerraform = true; | ||
867 | r1.BlockFly = true; | ||
868 | r1.AllowDamage = true; | ||
869 | r1.RestrictPushing = true; | ||
870 | r1.AllowLandResell = false; | ||
871 | r1.AllowLandJoinDivide = false; | ||
872 | r1.BlockShowInSearch = true; | ||
873 | r1.AgentLimit = agentlimit; | ||
874 | r1.ObjectBonus = objectbonus; | ||
875 | r1.Maturity = maturity; | ||
876 | r1.DisableScripts = true; | ||
877 | r1.DisableCollisions = true; | ||
878 | r1.DisablePhysics = true; | ||
879 | r1.TerrainTexture1 = tertex1; | ||
880 | r1.TerrainTexture2 = tertex2; | ||
881 | r1.TerrainTexture3 = tertex3; | ||
882 | r1.TerrainTexture4 = tertex4; | ||
883 | r1.Elevation1NW = elev1nw; | ||
884 | r1.Elevation2NW = elev2nw; | ||
885 | r1.Elevation1NE = elev1ne; | ||
886 | r1.Elevation2NE = elev2ne; | ||
887 | r1.Elevation1SE = elev1se; | ||
888 | r1.Elevation2SE = elev2se; | ||
889 | r1.Elevation1SW = elev1sw; | ||
890 | r1.Elevation2SW = elev2sw; | ||
891 | r1.WaterHeight = waterh; | ||
892 | r1.TerrainRaiseLimit = terrainraise; | ||
893 | r1.TerrainLowerLimit = terrainlower; | ||
894 | r1.UseEstateSun = false; | ||
895 | r1.Sandbox = true; | ||
896 | r1.SunVector = sunvector; | ||
897 | r1.TerrainImageID = terimgid; | ||
898 | r1.FixedSun = true; | ||
899 | r1.SunPosition = sunpos; | ||
900 | r1.Covenant = cov; | ||
901 | |||
902 | db.StoreRegionSettings(r1); | ||
903 | |||
904 | RegionSettings r1a = db.LoadRegionSettings(region1); | ||
905 | Assert.That(r1a.RegionUUID, Is.EqualTo(region1), "Assert.That(r1a.RegionUUID, Is.EqualTo(region1))"); | ||
906 | Assert.That(r1a.BlockTerraform,Is.True); | ||
907 | Assert.That(r1a.BlockFly,Is.True); | ||
908 | Assert.That(r1a.AllowDamage,Is.True); | ||
909 | Assert.That(r1a.RestrictPushing,Is.True); | ||
910 | Assert.That(r1a.AllowLandResell,Is.False); | ||
911 | Assert.That(r1a.AllowLandJoinDivide,Is.False); | ||
912 | Assert.That(r1a.BlockShowInSearch,Is.True); | ||
913 | Assert.That(r1a.AgentLimit,Is.EqualTo(agentlimit), "Assert.That(r1a.AgentLimit,Is.EqualTo(agentlimit))"); | ||
914 | Assert.That(r1a.ObjectBonus,Is.EqualTo(objectbonus), "Assert.That(r1a.ObjectBonus,Is.EqualTo(objectbonus))"); | ||
915 | Assert.That(r1a.Maturity,Is.EqualTo(maturity), "Assert.That(r1a.Maturity,Is.EqualTo(maturity))"); | ||
916 | Assert.That(r1a.DisableScripts,Is.True); | ||
917 | Assert.That(r1a.DisableCollisions,Is.True); | ||
918 | Assert.That(r1a.DisablePhysics,Is.True); | ||
919 | Assert.That(r1a.TerrainTexture1,Is.EqualTo(tertex1), "Assert.That(r1a.TerrainTexture1,Is.EqualTo(tertex1))"); | ||
920 | Assert.That(r1a.TerrainTexture2,Is.EqualTo(tertex2), "Assert.That(r1a.TerrainTexture2,Is.EqualTo(tertex2))"); | ||
921 | Assert.That(r1a.TerrainTexture3,Is.EqualTo(tertex3), "Assert.That(r1a.TerrainTexture3,Is.EqualTo(tertex3))"); | ||
922 | Assert.That(r1a.TerrainTexture4,Is.EqualTo(tertex4), "Assert.That(r1a.TerrainTexture4,Is.EqualTo(tertex4))"); | ||
923 | Assert.That(r1a.Elevation1NW,Is.EqualTo(elev1nw), "Assert.That(r1a.Elevation1NW,Is.EqualTo(elev1nw))"); | ||
924 | Assert.That(r1a.Elevation2NW,Is.EqualTo(elev2nw), "Assert.That(r1a.Elevation2NW,Is.EqualTo(elev2nw))"); | ||
925 | Assert.That(r1a.Elevation1NE,Is.EqualTo(elev1ne), "Assert.That(r1a.Elevation1NE,Is.EqualTo(elev1ne))"); | ||
926 | Assert.That(r1a.Elevation2NE,Is.EqualTo(elev2ne), "Assert.That(r1a.Elevation2NE,Is.EqualTo(elev2ne))"); | ||
927 | Assert.That(r1a.Elevation1SE,Is.EqualTo(elev1se), "Assert.That(r1a.Elevation1SE,Is.EqualTo(elev1se))"); | ||
928 | Assert.That(r1a.Elevation2SE,Is.EqualTo(elev2se), "Assert.That(r1a.Elevation2SE,Is.EqualTo(elev2se))"); | ||
929 | Assert.That(r1a.Elevation1SW,Is.EqualTo(elev1sw), "Assert.That(r1a.Elevation1SW,Is.EqualTo(elev1sw))"); | ||
930 | Assert.That(r1a.Elevation2SW,Is.EqualTo(elev2sw), "Assert.That(r1a.Elevation2SW,Is.EqualTo(elev2sw))"); | ||
931 | Assert.That(r1a.WaterHeight,Is.EqualTo(waterh), "Assert.That(r1a.WaterHeight,Is.EqualTo(waterh))"); | ||
932 | Assert.That(r1a.TerrainRaiseLimit,Is.EqualTo(terrainraise), "Assert.That(r1a.TerrainRaiseLimit,Is.EqualTo(terrainraise))"); | ||
933 | Assert.That(r1a.TerrainLowerLimit,Is.EqualTo(terrainlower), "Assert.That(r1a.TerrainLowerLimit,Is.EqualTo(terrainlower))"); | ||
934 | Assert.That(r1a.UseEstateSun,Is.False); | ||
935 | Assert.That(r1a.Sandbox,Is.True); | ||
936 | Assert.That(r1a.SunVector,Is.EqualTo(sunvector), "Assert.That(r1a.SunVector,Is.EqualTo(sunvector))"); | ||
937 | //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))"); | ||
938 | Assert.That(r1a.FixedSun,Is.True); | ||
939 | Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))"); | ||
940 | Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))"); | ||
941 | |||
942 | } | ||
943 | |||
944 | [Test] | ||
945 | public void T300_NoTerrain() | ||
946 | { | ||
947 | Assert.That(db.LoadTerrain(zero), Is.Null); | ||
948 | Assert.That(db.LoadTerrain(region1), Is.Null); | ||
949 | Assert.That(db.LoadTerrain(region2), Is.Null); | ||
950 | Assert.That(db.LoadTerrain(UUID.Random()), Is.Null); | ||
951 | } | ||
952 | |||
953 | [Test] | ||
954 | public void T301_CreateTerrain() | ||
955 | { | ||
956 | double[,] t1 = GenTerrain(height1); | ||
957 | db.StoreTerrain(t1, region1); | ||
958 | |||
959 | Assert.That(db.LoadTerrain(zero), Is.Null); | ||
960 | Assert.That(db.LoadTerrain(region1), Is.Not.Null); | ||
961 | Assert.That(db.LoadTerrain(region2), Is.Null); | ||
962 | Assert.That(db.LoadTerrain(UUID.Random()), Is.Null); | ||
963 | } | ||
964 | |||
965 | [Test] | ||
966 | public void T302_FetchTerrain() | ||
967 | { | ||
968 | double[,] baseterrain1 = GenTerrain(height1); | ||
969 | double[,] baseterrain2 = GenTerrain(height2); | ||
970 | double[,] t1 = db.LoadTerrain(region1); | ||
971 | Assert.That(CompareTerrain(t1, baseterrain1), Is.True); | ||
972 | Assert.That(CompareTerrain(t1, baseterrain2), Is.False); | ||
973 | } | ||
974 | |||
975 | [Test] | ||
976 | public void T303_UpdateTerrain() | ||
977 | { | ||
978 | double[,] baseterrain1 = GenTerrain(height1); | ||
979 | double[,] baseterrain2 = GenTerrain(height2); | ||
980 | db.StoreTerrain(baseterrain2, region1); | ||
981 | |||
982 | double[,] t1 = db.LoadTerrain(region1); | ||
983 | Assert.That(CompareTerrain(t1, baseterrain1), Is.False); | ||
984 | Assert.That(CompareTerrain(t1, baseterrain2), Is.True); | ||
985 | } | ||
986 | |||
987 | [Test] | ||
988 | public void T400_EmptyLand() | ||
989 | { | ||
990 | Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))"); | ||
991 | Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))"); | ||
992 | Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))"); | ||
993 | Assert.That(db.LoadLandObjects(UUID.Random()).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(UUID.Random()).Count, Is.EqualTo(0))"); | ||
994 | } | ||
995 | |||
996 | // TODO: we should have real land tests, but Land is so | ||
997 | // intermingled with scene that you can't test it without a | ||
998 | // valid scene. That requires some disagregation. | ||
999 | |||
1000 | |||
1001 | //************************************************************************************// | ||
1002 | // Extra private methods | ||
1003 | |||
1004 | private double[,] GenTerrain(double value) | ||
1005 | { | ||
1006 | double[,] terret = new double[Constants.RegionSize, Constants.RegionSize]; | ||
1007 | terret.Initialize(); | ||
1008 | for (int x = 0; x < Constants.RegionSize; x++) | ||
1009 | for (int y = 0; y < Constants.RegionSize; y++) | ||
1010 | terret[x,y] = value; | ||
1011 | |||
1012 | return terret; | ||
1013 | } | ||
1014 | |||
1015 | private bool CompareTerrain(double[,] one, double[,] two) | ||
1016 | { | ||
1017 | for (int x = 0; x < Constants.RegionSize; x++) | ||
1018 | for (int y = 0; y < Constants.RegionSize; y++) | ||
1019 | if (one[x,y] != two[x,y]) | ||
1020 | return false; | ||
1021 | |||
1022 | return true; | ||
1023 | } | ||
1024 | |||
1025 | |||
1026 | private SceneObjectGroup FindSOG(string name, UUID r) | ||
1027 | { | ||
1028 | List<SceneObjectGroup> objs = db.LoadObjects(r); | ||
1029 | foreach (SceneObjectGroup sog in objs) | ||
1030 | { | ||
1031 | SceneObjectPart p = sog.RootPart; | ||
1032 | if (p.Name == name) { | ||
1033 | RegionInfo regionInfo = new RegionInfo(); | ||
1034 | regionInfo.RegionID = r; | ||
1035 | regionInfo.RegionLocX = 0; | ||
1036 | regionInfo.RegionLocY = 0; | ||
1037 | |||
1038 | Scene scene = new Scene(regionInfo); | ||
1039 | sog.SetScene(scene); | ||
1040 | |||
1041 | return sog; | ||
1042 | } | ||
1043 | } | ||
1044 | |||
1045 | return null; | ||
1046 | } | ||
1047 | |||
1048 | // This builds a minimalistic Prim, 1 SOG with 1 root SOP. A | ||
1049 | // common failure case is people adding new fields that aren't | ||
1050 | // initialized, but have non-null db constraints. We should | ||
1051 | // honestly be passing more and more null things in here. | ||
1052 | // | ||
1053 | // Please note that in Sqlite.BuildPrim there is a commented out inline version | ||
1054 | // of this so you can debug and step through the build process and check the fields | ||
1055 | // | ||
1056 | // Real World Value: Tests for situation where extending a SceneObjectGroup/SceneObjectPart | ||
1057 | // causes the application to crash at the database layer because of null values | ||
1058 | // in NOT NULL fields | ||
1059 | // | ||
1060 | private SceneObjectGroup NewSOG(string name, UUID uuid, UUID regionId) | ||
1061 | { | ||
1062 | RegionInfo regionInfo = new RegionInfo(); | ||
1063 | regionInfo.RegionID = regionId; | ||
1064 | regionInfo.RegionLocX = 0; | ||
1065 | regionInfo.RegionLocY = 0; | ||
1066 | |||
1067 | Scene scene = new Scene(regionInfo); | ||
1068 | |||
1069 | SceneObjectPart sop = new SceneObjectPart(); | ||
1070 | sop.Name = name; | ||
1071 | sop.Description = name; | ||
1072 | sop.Text = RandomName(); | ||
1073 | sop.SitName = RandomName(); | ||
1074 | sop.TouchName = RandomName(); | ||
1075 | sop.UUID = uuid; | ||
1076 | sop.Shape = PrimitiveBaseShape.Default; | ||
1077 | |||
1078 | SceneObjectGroup sog = new SceneObjectGroup(sop); | ||
1079 | sog.SetScene(scene); | ||
1080 | |||
1081 | return sog; | ||
1082 | } | ||
1083 | |||
1084 | private SceneObjectPart NewSOP(string name, UUID uuid) | ||
1085 | { | ||
1086 | SceneObjectPart sop = new SceneObjectPart(); | ||
1087 | sop.Name = name; | ||
1088 | sop.Description = name; | ||
1089 | sop.Text = RandomName(); | ||
1090 | sop.SitName = RandomName(); | ||
1091 | sop.TouchName = RandomName(); | ||
1092 | sop.UUID = uuid; | ||
1093 | sop.Shape = PrimitiveBaseShape.Default; | ||
1094 | return sop; | ||
1095 | } | ||
1096 | |||
1097 | // These are copied from the Inventory Item tests | ||
1098 | |||
1099 | private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset) | ||
1100 | { | ||
1101 | InventoryItemBase i = new InventoryItemBase(); | ||
1102 | i.ID = id; | ||
1103 | i.Folder = parent; | ||
1104 | i.Owner = owner; | ||
1105 | i.CreatorId = owner.ToString(); | ||
1106 | i.Name = name; | ||
1107 | i.Description = name; | ||
1108 | i.AssetID = asset; | ||
1109 | return i; | ||
1110 | } | ||
1111 | |||
1112 | private static string RandomName() | ||
1113 | { | ||
1114 | StringBuilder name = new StringBuilder(); | ||
1115 | int size = random.Next(5,12); | ||
1116 | char ch ; | ||
1117 | for (int i=0; i<size; i++) | ||
1118 | { | ||
1119 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
1120 | name.Append(ch); | ||
1121 | } | ||
1122 | return name.ToString(); | ||
1123 | } | ||
1124 | // private InventoryFolderBase NewFolder(UUID id, UUID parent, UUID owner, string name) | ||
1125 | // { | ||
1126 | // InventoryFolderBase f = new InventoryFolderBase(); | ||
1127 | // f.ID = id; | ||
1128 | // f.ParentID = parent; | ||
1129 | // f.Owner = owner; | ||
1130 | // f.Name = name; | ||
1131 | // return f; | ||
1132 | // } | ||
1133 | } | ||
1134 | } | ||