aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Tests/MundaneFrameworkTests.cs311
1 files changed, 311 insertions, 0 deletions
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
new file mode 100644
index 0000000..04be083
--- /dev/null
+++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
@@ -0,0 +1,311 @@
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
28using NUnit.Framework;
29using OpenSim.Framework;
30using OpenMetaverse;
31using OpenMetaverse.StructuredData;
32using System;
33using System.Globalization;
34using System.Threading;
35
36namespace OpenSim.Framework.Tests
37{
38 [TestFixture]
39 public class MundaneFrameworkTests
40 {
41 private bool m_RegionSettingsOnSaveEventFired;
42 private bool m_RegionLightShareDataOnSaveEventFired;
43
44
45 [Test]
46 public void ChildAgentDataUpdate01()
47 {
48 // code coverage
49 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
50 Assert.IsFalse(cadu.alwaysrun, "Default is false");
51 }
52
53 [Test]
54 public void AgentPositionTest01()
55 {
56 UUID AgentId1 = UUID.Random();
57 UUID SessionId1 = UUID.Random();
58 uint CircuitCode1 = uint.MinValue;
59 Vector3 Size1 = Vector3.UnitZ;
60 Vector3 Position1 = Vector3.UnitX;
61 Vector3 LeftAxis1 = Vector3.UnitY;
62 Vector3 UpAxis1 = Vector3.UnitZ;
63 Vector3 AtAxis1 = Vector3.UnitX;
64
65 ulong RegionHandle1 = ulong.MinValue;
66 byte[] Throttles1 = new byte[] {0, 1, 0};
67
68 Vector3 Velocity1 = Vector3.Zero;
69 float Far1 = 256;
70
71 bool ChangedGrid1 = false;
72 Vector3 Center1 = Vector3.Zero;
73
74 AgentPosition position1 = new AgentPosition();
75 position1.AgentID = AgentId1;
76 position1.SessionID = SessionId1;
77 position1.CircuitCode = CircuitCode1;
78 position1.Size = Size1;
79 position1.Position = Position1;
80 position1.LeftAxis = LeftAxis1;
81 position1.UpAxis = UpAxis1;
82 position1.AtAxis = AtAxis1;
83 position1.RegionHandle = RegionHandle1;
84 position1.Throttles = Throttles1;
85 position1.Velocity = Velocity1;
86 position1.Far = Far1;
87 position1.ChangedGrid = ChangedGrid1;
88 position1.Center = Center1;
89
90 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
91 cadu.AgentID = AgentId1.Guid;
92 cadu.ActiveGroupID = UUID.Zero.Guid;
93 cadu.throttles = Throttles1;
94 cadu.drawdistance = Far1;
95 cadu.Position = Position1;
96 cadu.Velocity = Velocity1;
97 cadu.regionHandle = RegionHandle1;
98 cadu.cameraPosition = Center1;
99 cadu.AVHeight = Size1.Z;
100
101 AgentPosition position2 = new AgentPosition();
102 position2.CopyFrom(cadu);
103
104 Assert.IsTrue(
105 position2.AgentID == position1.AgentID
106 && position2.Size == position1.Size
107 && position2.Position == position1.Position
108 && position2.Velocity == position1.Velocity
109 && position2.Center == position1.Center
110 && position2.RegionHandle == position1.RegionHandle
111 && position2.Far == position1.Far
112
113 ,"Copy From ChildAgentDataUpdate failed");
114
115 position2 = new AgentPosition();
116
117 Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition");
118 position2.Unpack(position1.Pack());
119
120 Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed");
121 Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed");
122 Assert.IsTrue(position2.Velocity == position1.Velocity, "Velocity didn't unpack the same way it packed");
123 Assert.IsTrue(position2.SessionID == position1.SessionID, "SessionID didn't unpack the same way it packed");
124 Assert.IsTrue(position2.CircuitCode == position1.CircuitCode, "CircuitCode didn't unpack the same way it packed");
125 Assert.IsTrue(position2.LeftAxis == position1.LeftAxis, "LeftAxis didn't unpack the same way it packed");
126 Assert.IsTrue(position2.UpAxis == position1.UpAxis, "UpAxis didn't unpack the same way it packed");
127 Assert.IsTrue(position2.AtAxis == position1.AtAxis, "AtAxis didn't unpack the same way it packed");
128 Assert.IsTrue(position2.RegionHandle == position1.RegionHandle, "RegionHandle didn't unpack the same way it packed");
129 Assert.IsTrue(position2.ChangedGrid == position1.ChangedGrid, "ChangedGrid didn't unpack the same way it packed");
130 Assert.IsTrue(position2.Center == position1.Center, "Center didn't unpack the same way it packed");
131 Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed");
132
133 }
134
135 [Test]
136 public void RegionSettingsTest01()
137 {
138 RegionSettings settings = new RegionSettings();
139 settings.OnSave += RegionSaveFired;
140 settings.Save();
141 settings.OnSave -= RegionSaveFired;
142
143 string str = settings.LoadedCreationDate;
144 int dt = settings.LoadedCreationDateTime;
145 string id = settings.LoadedCreationID;
146 string time = settings.LoadedCreationTime;
147
148 Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire");
149
150 }
151 public void RegionSaveFired(RegionSettings settings)
152 {
153 m_RegionSettingsOnSaveEventFired = true;
154 }
155
156 [Test]
157 public void InventoryItemBaseConstructorTest01()
158 {
159 InventoryItemBase b1 = new InventoryItemBase();
160 Assert.That(b1.ID == UUID.Zero, "void constructor should create an inventory item with ID = UUID.Zero");
161 Assert.That(b1.Owner == UUID.Zero, "void constructor should create an inventory item with Owner = UUID.Zero");
162
163 UUID ItemID = UUID.Random();
164 UUID OwnerID = UUID.Random();
165
166 InventoryItemBase b2 = new InventoryItemBase(ItemID);
167 Assert.That(b2.ID == ItemID, "ID constructor should create an inventory item with ID = ItemID");
168 Assert.That(b2.Owner == UUID.Zero, "ID constructor should create an inventory item with Owner = UUID.Zero");
169
170 InventoryItemBase b3 = new InventoryItemBase(ItemID,OwnerID);
171 Assert.That(b3.ID == ItemID, "ID,OwnerID constructor should create an inventory item with ID = ItemID");
172 Assert.That(b3.Owner == OwnerID, "ID,OwnerID constructor should create an inventory item with Owner = OwnerID");
173
174 }
175
176 [Test]
177 public void AssetMetaDataNonNullContentTypeTest01()
178 {
179 AssetMetadata assetMetadata = new AssetMetadata();
180 assetMetadata.ContentType = "image/jp2";
181 Assert.That(assetMetadata.Type == (sbyte)AssetType.Texture, "Content type should be AssetType.Texture");
182 Assert.That(assetMetadata.ContentType == "image/jp2", "Text of content type should be image/jp2");
183 UUID rndID = UUID.Random();
184 assetMetadata.ID = rndID.ToString();
185 Assert.That(assetMetadata.ID.ToLower() == rndID.ToString().ToLower(), "assetMetadata.ID Setter/Getter not Consistent");
186 DateTime fixedTime = DateTime.Now;
187 assetMetadata.CreationDate = fixedTime;
188 }
189
190 [Test]
191 public void RegionLightShareDataCloneSaveTest01()
192 {
193 RegionLightShareData rlsd = new RegionLightShareData();
194 rlsd.OnSave += RegionLightShareDataSaveFired;
195 rlsd.Save();
196 rlsd.OnSave -= RegionLightShareDataSaveFired;
197 Assert.IsTrue(m_RegionLightShareDataOnSaveEventFired, "OnSave Event Never Fired");
198
199 object o = rlsd.Clone();
200 RegionLightShareData dupe = (RegionLightShareData) o;
201 Assert.IsTrue(rlsd.sceneGamma == dupe.sceneGamma, "Memberwise Clone of RegionLightShareData failed");
202 }
203 public void RegionLightShareDataSaveFired(RegionLightShareData settings)
204 {
205 m_RegionLightShareDataOnSaveEventFired = true;
206 }
207
208 [Test]
209 public void EstateSettingsMundateTests()
210 {
211 EstateSettings es = new EstateSettings();
212 es.AddBan(null);
213 UUID bannedUserId = UUID.Random();
214 es.AddBan(new EstateBan()
215 { BannedHostAddress = string.Empty,
216 BannedHostIPMask = string.Empty,
217 BannedHostNameMask = string.Empty,
218 BannedUserID = bannedUserId}
219 );
220 Assert.IsTrue(es.IsBanned(bannedUserId), "User Should be banned but is not.");
221 Assert.IsFalse(es.IsBanned(UUID.Zero), "User Should not be banned but is.");
222
223 es.RemoveBan(bannedUserId);
224
225 Assert.IsFalse(es.IsBanned(bannedUserId), "User Should not be banned but is.");
226
227 es.AddEstateManager(UUID.Zero);
228
229 es.AddEstateManager(bannedUserId);
230 Assert.IsTrue(es.IsEstateManager(bannedUserId), "bannedUserId should be EstateManager but isn't.");
231
232 es.RemoveEstateManager(bannedUserId);
233 Assert.IsFalse(es.IsEstateManager(bannedUserId), "bannedUserID is estateManager but shouldn't be");
234
235 Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't");
236
237 es.AddEstateUser(bannedUserId);
238
239 Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should");
240 es.RemoveEstateUser(bannedUserId);
241
242 es.AddEstateManager(bannedUserId);
243
244 Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should");
245
246 Assert.That(es.EstateGroups.Length == 0, "No Estate Groups Added.. so the array should be 0 length");
247
248 es.AddEstateGroup(bannedUserId);
249
250 Assert.That(es.EstateGroups.Length == 1, "1 Estate Groups Added.. so the array should be 1 length");
251
252 Assert.That(es.EstateGroups[0] == bannedUserId,"User ID should be in EstateGroups");
253
254 }
255
256 [Test]
257 public void InventoryFolderBaseConstructorTest01()
258 {
259 UUID uuid1 = UUID.Random();
260 UUID uuid2 = UUID.Random();
261
262 InventoryFolderBase fld = new InventoryFolderBase(uuid1);
263 Assert.That(fld.ID == uuid1, "ID constructor failed to save value in ID field.");
264
265 fld = new InventoryFolderBase(uuid1, uuid2);
266 Assert.That(fld.ID == uuid1, "ID,Owner constructor failed to save value in ID field.");
267 Assert.That(fld.Owner == uuid2, "ID,Owner constructor failed to save value in ID field.");
268 }
269
270 [Test]
271 public void AsssetBaseConstructorTest01()
272 {
273 AssetBase abase = new AssetBase();
274 Assert.IsNotNull(abase.Metadata, "void constructor of AssetBase should have created a MetaData element but didn't.");
275 UUID itemID = UUID.Random();
276 UUID creatorID = UUID.Random();
277 abase = new AssetBase(itemID.ToString(), "test item", (sbyte) AssetType.Texture, creatorID.ToString());
278
279 Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase should have created a MetaData element but didn't.");
280 Assert.That(abase.ID == itemID.ToString(), "string,string,sbyte,string constructor failed to set ID property");
281 Assert.That(abase.Metadata.CreatorID == creatorID.ToString(), "string,string,sbyte,string constructor failed to set Creator ID");
282
283
284 abase = new AssetBase(itemID.ToString(), "test item", -1, creatorID.ToString());
285 Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase with unknown type should have created a MetaData element but didn't.");
286 Assert.That(abase.Metadata.Type == -1, "Unknown Type passed to string,string,sbyte,string constructor and was a known type when it came out again");
287
288 AssetMetadata metts = new AssetMetadata();
289 metts.FullID = itemID;
290 metts.ID = string.Empty;
291 metts.Name = "test item";
292 abase.Metadata = metts;
293
294 Assert.That(abase.ToString() == itemID.ToString(), "ToString is overriden to be fullID.ToString()");
295 Assert.That(abase.ID == itemID.ToString(),"ID should be MetaData.FullID.ToString() when string.empty or null is provided to the ID property");
296 }
297
298 [Test]
299 public void CultureSetCultureTest01()
300 {
301 CultureInfo ci = new CultureInfo("en-US", false);
302 Culture.SetCurrentCulture();
303 Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US");
304
305 }
306
307
308
309 }
310}
311