aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Tests/BasicRegionTest.cs
diff options
context:
space:
mode:
authorSean Dague2008-09-12 18:13:43 +0000
committerSean Dague2008-09-12 18:13:43 +0000
commit9349cf314963a2b74727b86e37b41642c7212d6d (patch)
treee52240f71b1bce3531649ce1629e1b62219f6827 /OpenSim/Data/Tests/BasicRegionTest.cs
parentchange order in prebuild.xml so this works in nant on a clean (diff)
downloadopensim-SC-9349cf314963a2b74727b86e37b41642c7212d6d.zip
opensim-SC-9349cf314963a2b74727b86e37b41642c7212d6d.tar.gz
opensim-SC-9349cf314963a2b74727b86e37b41642c7212d6d.tar.bz2
opensim-SC-9349cf314963a2b74727b86e37b41642c7212d6d.tar.xz
move the actual [Test] methods for databases to OpenSim.Data.Tests
classes. This did mean loosing 1 unit test that was actually testing an sqlite function directly instead of the interface.
Diffstat (limited to 'OpenSim/Data/Tests/BasicRegionTest.cs')
-rw-r--r--OpenSim/Data/Tests/BasicRegionTest.cs132
1 files changed, 132 insertions, 0 deletions
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs
new file mode 100644
index 0000000..39692f1
--- /dev/null
+++ b/OpenSim/Data/Tests/BasicRegionTest.cs
@@ -0,0 +1,132 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenSim.Framework;
33using OpenSim.Data;
34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Scenes;
36using OpenMetaverse;
37
38namespace OpenSim.Data.Tests
39{
40 public class BasicRegionTest
41 {
42 public IRegionDataStore db;
43 public UUID region;
44
45 public void SuperInit()
46 {
47 region = UUID.Random();
48 }
49
50 [Test]
51 public void T001_LoadEmpty()
52 {
53 List<SceneObjectGroup> objs = db.LoadObjects(region);
54 Assert.AreEqual(0, objs.Count);
55 }
56
57 // SOG round trips
58 // * store objects, make sure they save
59 // * update
60
61 [Test]
62 public void T010_StoreSimpleObject()
63 {
64 SceneObjectGroup sog = NewSOG("object1");
65 SceneObjectGroup sog2 = NewSOG("object2");
66
67 db.StoreObject(sog, region);
68 db.StoreObject(sog2, region);
69
70 // This tests the ADO.NET driver
71 List<SceneObjectGroup> objs = db.LoadObjects(region);
72 Assert.AreEqual(2, objs.Count);
73 }
74
75 [Test]
76 public void T011_ObjectNames()
77 {
78 List<SceneObjectGroup> objs = db.LoadObjects(region);
79 foreach (SceneObjectGroup sog in objs)
80 {
81 SceneObjectPart p = sog.RootPart;
82 Assert.That("", Text.DoesNotMatch(p.Name));
83 Assert.That(p.Name, Text.Matches(p.Description));
84 }
85 }
86
87 [Test]
88 public void T012_UpdateObject()
89 {
90 string text = "object1 text";
91 SceneObjectGroup sog = FindSOG("object1", region);
92 sog.RootPart.Text = text;
93 db.StoreObject(sog, region);
94
95 sog = FindSOG("object1", region);
96 Assert.That(text, Text.Matches(sog.RootPart.Text));
97 }
98
99 // Extra private methods
100
101 private SceneObjectGroup FindSOG(string name, UUID r)
102 {
103 List<SceneObjectGroup> objs = db.LoadObjects(r);
104 foreach (SceneObjectGroup sog in objs)
105 {
106 SceneObjectPart p = sog.RootPart;
107 if (p.Name == name) {
108 return sog;
109 }
110 }
111 return null;
112 }
113
114 private SceneObjectGroup NewSOG(string name)
115 {
116 SceneObjectGroup sog = new SceneObjectGroup();
117 SceneObjectPart sop = new SceneObjectPart();
118 sop.LocalId = 1;
119 sop.Name = name;
120 sop.Description = name;
121 sop.Text = "";
122 sop.SitName = "";
123 sop.TouchName = "";
124 sop.UUID = UUID.Random();
125 sop.Shape = PrimitiveBaseShape.Default;
126 sog.AddPart(sop);
127 sog.RootPart = sop;
128 return sog;
129 }
130
131 }
132} \ No newline at end of file