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