diff options
Diffstat (limited to 'OpenSim/Data/Tests/BasicRegionTest.cs')
-rw-r--r-- | OpenSim/Data/Tests/BasicRegionTest.cs | 91 |
1 files changed, 81 insertions, 10 deletions
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs index 5fca534..7b5284a 100644 --- a/OpenSim/Data/Tests/BasicRegionTest.cs +++ b/OpenSim/Data/Tests/BasicRegionTest.cs | |||
@@ -40,17 +40,31 @@ namespace OpenSim.Data.Tests | |||
40 | public class BasicRegionTest | 40 | public class BasicRegionTest |
41 | { | 41 | { |
42 | public IRegionDataStore db; | 42 | public IRegionDataStore db; |
43 | public UUID region; | 43 | public UUID region1; |
44 | public UUID region2; | ||
45 | public double height1; | ||
46 | public double height2; | ||
44 | 47 | ||
45 | public void SuperInit() | 48 | public void SuperInit() |
46 | { | 49 | { |
47 | region = UUID.Random(); | 50 | try |
51 | { | ||
52 | log4net.Config.XmlConfigurator.Configure(); | ||
53 | } | ||
54 | catch (Exception) | ||
55 | { | ||
56 | // I don't care, just leave log4net off | ||
57 | } | ||
58 | |||
59 | region1 = UUID.Random(); | ||
60 | height1 = 20; | ||
61 | height2 = 100; | ||
48 | } | 62 | } |
49 | 63 | ||
50 | [Test] | 64 | [Test] |
51 | public void T001_LoadEmpty() | 65 | public void T001_LoadEmpty() |
52 | { | 66 | { |
53 | List<SceneObjectGroup> objs = db.LoadObjects(region); | 67 | List<SceneObjectGroup> objs = db.LoadObjects(region1); |
54 | Assert.That(objs.Count, Is.EqualTo(0)); | 68 | Assert.That(objs.Count, Is.EqualTo(0)); |
55 | } | 69 | } |
56 | 70 | ||
@@ -64,18 +78,18 @@ namespace OpenSim.Data.Tests | |||
64 | SceneObjectGroup sog = NewSOG("object1"); | 78 | SceneObjectGroup sog = NewSOG("object1"); |
65 | SceneObjectGroup sog2 = NewSOG("object2"); | 79 | SceneObjectGroup sog2 = NewSOG("object2"); |
66 | 80 | ||
67 | db.StoreObject(sog, region); | 81 | db.StoreObject(sog, region1); |
68 | db.StoreObject(sog2, region); | 82 | db.StoreObject(sog2, region1); |
69 | 83 | ||
70 | // This tests the ADO.NET driver | 84 | // This tests the ADO.NET driver |
71 | List<SceneObjectGroup> objs = db.LoadObjects(region); | 85 | List<SceneObjectGroup> objs = db.LoadObjects(region1); |
72 | Assert.That(objs.Count, Is.EqualTo(2)); | 86 | Assert.That(objs.Count, Is.EqualTo(2)); |
73 | } | 87 | } |
74 | 88 | ||
75 | [Test] | 89 | [Test] |
76 | public void T011_ObjectNames() | 90 | public void T011_ObjectNames() |
77 | { | 91 | { |
78 | List<SceneObjectGroup> objs = db.LoadObjects(region); | 92 | List<SceneObjectGroup> objs = db.LoadObjects(region1); |
79 | foreach (SceneObjectGroup sog in objs) | 93 | foreach (SceneObjectGroup sog in objs) |
80 | { | 94 | { |
81 | SceneObjectPart p = sog.RootPart; | 95 | SceneObjectPart p = sog.RootPart; |
@@ -88,16 +102,73 @@ namespace OpenSim.Data.Tests | |||
88 | public void T012_UpdateObject() | 102 | public void T012_UpdateObject() |
89 | { | 103 | { |
90 | string text = "object1 text"; | 104 | string text = "object1 text"; |
91 | SceneObjectGroup sog = FindSOG("object1", region); | 105 | SceneObjectGroup sog = FindSOG("object1", region1); |
92 | sog.RootPart.Text = text; | 106 | sog.RootPart.Text = text; |
93 | db.StoreObject(sog, region); | 107 | db.StoreObject(sog, region1); |
94 | 108 | ||
95 | sog = FindSOG("object1", region); | 109 | sog = FindSOG("object1", region1); |
96 | Assert.That(text, Is.EqualTo(sog.RootPart.Text)); | 110 | Assert.That(text, Is.EqualTo(sog.RootPart.Text)); |
97 | } | 111 | } |
98 | 112 | ||
113 | [Test] | ||
114 | public void T300_NoTerrain() | ||
115 | { | ||
116 | double[,] t1 = db.LoadTerrain(region1); | ||
117 | } | ||
118 | |||
119 | [Test] | ||
120 | public void T301_CreateTerrain() | ||
121 | { | ||
122 | double[,] t1 = GenTerrain(height1); | ||
123 | db.StoreTerrain(t1, region1); | ||
124 | } | ||
125 | |||
126 | [Test] | ||
127 | public void T302_FetchTerrain() | ||
128 | { | ||
129 | double[,] baseterrain1 = GenTerrain(height1); | ||
130 | double[,] baseterrain2 = GenTerrain(height2); | ||
131 | double[,] t1 = db.LoadTerrain(region1); | ||
132 | Assert.That(CompareTerrain(t1, baseterrain1), Is.True); | ||
133 | Assert.That(CompareTerrain(t1, baseterrain2), Is.False); | ||
134 | } | ||
135 | |||
136 | [Test] | ||
137 | public void T303_UpdateTerrain() | ||
138 | { | ||
139 | double[,] baseterrain1 = GenTerrain(height1); | ||
140 | double[,] baseterrain2 = GenTerrain(height2); | ||
141 | db.StoreTerrain(baseterrain2, region1); | ||
142 | |||
143 | double[,] t1 = db.LoadTerrain(region1); | ||
144 | Assert.That(CompareTerrain(t1, baseterrain1), Is.False); | ||
145 | Assert.That(CompareTerrain(t1, baseterrain2), Is.True); | ||
146 | } | ||
147 | |||
99 | // Extra private methods | 148 | // Extra private methods |
100 | 149 | ||
150 | private double[,] GenTerrain(double value) | ||
151 | { | ||
152 | double[,] terret = new double[256,256]; | ||
153 | terret.Initialize(); | ||
154 | for (int x = 0; x < 256; x++) | ||
155 | for (int y = 0; y < 256; y++) | ||
156 | terret[x,y] = value; | ||
157 | |||
158 | return terret; | ||
159 | } | ||
160 | |||
161 | private bool CompareTerrain(double[,] one, double[,] two) | ||
162 | { | ||
163 | for (int x = 0; x < 256; x++) | ||
164 | for (int y = 0; y < 256; y++) | ||
165 | if (one[x,y] != two[x,y]) | ||
166 | return false; | ||
167 | |||
168 | return true; | ||
169 | } | ||
170 | |||
171 | |||
101 | private SceneObjectGroup FindSOG(string name, UUID r) | 172 | private SceneObjectGroup FindSOG(string name, UUID r) |
102 | { | 173 | { |
103 | List<SceneObjectGroup> objs = db.LoadObjects(r); | 174 | List<SceneObjectGroup> objs = db.LoadObjects(r); |