aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/Tests/MundaneFrameworkTests.cs140
-rw-r--r--OpenSim/Framework/Tests/UtilTest.cs58
2 files changed, 198 insertions, 0 deletions
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
index e2e08c0..0c588eb 100644
--- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
+++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
@@ -29,12 +29,17 @@ using NUnit.Framework;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenMetaverse.StructuredData; 31using OpenMetaverse.StructuredData;
32using System;
32 33
33namespace OpenSim.Framework.Tests 34namespace OpenSim.Framework.Tests
34{ 35{
35 [TestFixture] 36 [TestFixture]
36 public class MundaneFrameworkTests 37 public class MundaneFrameworkTests
37 { 38 {
39 private bool m_RegionSettingsOnSaveEventFired;
40 private bool m_RegionLightShareDataOnSaveEventFired;
41
42
38 [Test] 43 [Test]
39 public void ChildAgentDataUpdate01() 44 public void ChildAgentDataUpdate01()
40 { 45 {
@@ -124,6 +129,141 @@ namespace OpenSim.Framework.Tests
124 Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed"); 129 Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed");
125 130
126 } 131 }
132
133 [Test]
134 public void RegionSettingsTest01()
135 {
136 RegionSettings settings = new RegionSettings();
137 settings.OnSave += RegionSaveFired;
138 settings.Save();
139 settings.OnSave -= RegionSaveFired;
140
141 string str = settings.LoadedCreationDate;
142 int dt = settings.LoadedCreationDateTime;
143 string id = settings.LoadedCreationID;
144 string time = settings.LoadedCreationTime;
145
146 Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire");
147
148 }
149 public void RegionSaveFired(RegionSettings settings)
150 {
151 m_RegionSettingsOnSaveEventFired = true;
152 }
153
154 [Test]
155 public void InventoryItemBaseConstructorTest01()
156 {
157 InventoryItemBase b1 = new InventoryItemBase();
158 Assert.That(b1.ID == UUID.Zero, "void constructor should create an inventory item with ID = UUID.Zero");
159 Assert.That(b1.Owner == UUID.Zero, "void constructor should create an inventory item with Owner = UUID.Zero");
160
161 UUID ItemID = UUID.Random();
162 UUID OwnerID = UUID.Random();
163
164 InventoryItemBase b2 = new InventoryItemBase(ItemID);
165 Assert.That(b2.ID == ItemID, "ID constructor should create an inventory item with ID = ItemID");
166 Assert.That(b2.Owner == UUID.Zero, "ID constructor should create an inventory item with Owner = UUID.Zero");
167
168 InventoryItemBase b3 = new InventoryItemBase(ItemID,OwnerID);
169 Assert.That(b3.ID == ItemID, "ID,OwnerID constructor should create an inventory item with ID = ItemID");
170 Assert.That(b3.Owner == OwnerID, "ID,OwnerID constructor should create an inventory item with Owner = OwnerID");
171
172 }
173
174 [Test]
175 public void AssetMetaDataNonNullContentTypeTest01()
176 {
177 AssetMetadata assetMetadata = new AssetMetadata();
178 assetMetadata.ContentType = "image/jp2";
179 Assert.That(assetMetadata.Type == (sbyte)AssetType.Texture, "Content type should be AssetType.Texture");
180 Assert.That(assetMetadata.ContentType == "image/jp2", "Text of content type should be image/jp2");
181 UUID rndID = UUID.Random();
182 assetMetadata.ID = rndID.ToString();
183 Assert.That(assetMetadata.ID.ToLower() == rndID.ToString().ToLower(), "assetMetadata.ID Setter/Getter not Consistent");
184 DateTime fixedTime = DateTime.Now;
185 assetMetadata.CreationDate = fixedTime;
186 }
187
188 [Test]
189 public void RegionLightShareDataCloneSaveTest01()
190 {
191 RegionLightShareData rlsd = new RegionLightShareData();
192 rlsd.OnSave += RegionLightShareDataSaveFired;
193 rlsd.Save();
194 rlsd.OnSave -= RegionLightShareDataSaveFired;
195 Assert.IsTrue(m_RegionLightShareDataOnSaveEventFired, "OnSave Event Never Fired");
196
197 object o = rlsd.Clone();
198 RegionLightShareData dupe = (RegionLightShareData) o;
199 Assert.IsTrue(rlsd.sceneGamma == dupe.sceneGamma, "Memberwise Clone of RegionLightShareData failed");
200 }
201 public void RegionLightShareDataSaveFired(RegionLightShareData settings)
202 {
203 m_RegionLightShareDataOnSaveEventFired = true;
204 }
205
206 [Test]
207 public void EstateSettingsMundateTests()
208 {
209 EstateSettings es = new EstateSettings();
210 es.AddBan(null);
211 UUID bannedUserId = UUID.Random();
212 es.AddBan(new EstateBan()
213 { BannedHostAddress = string.Empty,
214 BannedHostIPMask = string.Empty,
215 BannedHostNameMask = string.Empty,
216 BannedUserID = bannedUserId}
217 );
218 Assert.IsTrue(es.IsBanned(bannedUserId), "User Should be banned but is not.");
219 Assert.IsFalse(es.IsBanned(UUID.Zero), "User Should not be banned but is.");
220
221 es.RemoveBan(bannedUserId);
222
223 Assert.IsFalse(es.IsBanned(bannedUserId), "User Should not be banned but is.");
224
225 es.AddEstateManager(UUID.Zero);
226
227 es.AddEstateManager(bannedUserId);
228 Assert.IsTrue(es.IsEstateManager(bannedUserId), "bannedUserId should be EstateManager but isn't.");
229
230 es.RemoveEstateManager(bannedUserId);
231 Assert.IsFalse(es.IsEstateManager(bannedUserId), "bannedUserID is estateManager but shouldn't be");
232
233 Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't");
234
235 es.AddEstateUser(bannedUserId);
236
237 Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should");
238 es.RemoveEstateUser(bannedUserId);
239
240 es.AddEstateManager(bannedUserId);
241
242 Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should");
243
244 Assert.That(es.EstateGroups.Length == 0, "No Estate Groups Added.. so the array should be 0 length");
245
246 es.AddEstateGroup(bannedUserId);
247
248 Assert.That(es.EstateGroups.Length == 1, "1 Estate Groups Added.. so the array should be 1 length");
249
250 Assert.That(es.EstateGroups[0] == bannedUserId,"User ID should be in EstateGroups");
251
252 }
253
254 [Test]
255 public void InventoryFolderBaseConstructorTest01()
256 {
257 UUID uuid1 = UUID.Random();
258 UUID uuid2 = UUID.Random();
259
260 InventoryFolderBase fld = new InventoryFolderBase(uuid1);
261 Assert.That(fld.ID == uuid1, "ID constructor failed to save value in ID field.");
262
263 fld = new InventoryFolderBase(uuid1, uuid2);
264 Assert.That(fld.ID == uuid1, "ID,Owner constructor failed to save value in ID field.");
265 Assert.That(fld.Owner == uuid2, "ID,Owner constructor failed to save value in ID field.");
266 }
127 267
128 268
129 } 269 }
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs
index 45d822c..d04cbc6 100644
--- a/OpenSim/Framework/Tests/UtilTest.cs
+++ b/OpenSim/Framework/Tests/UtilTest.cs
@@ -170,5 +170,63 @@ namespace OpenSim.Framework.Tests
170 // Varying secrets should not eqal the same 170 // Varying secrets should not eqal the same
171 Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2")); 171 Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2"));
172 } 172 }
173
174 [Test]
175 public void SLUtilTests()
176 {
177 int[] assettypes = new int[]{-1,0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
178 ,23,24,25,46,47,48};
179 string[] contenttypes = new string[]
180 {
181 "application/octet-stream",
182 "image/x-j2c",
183 "audio/ogg",
184 "application/vnd.ll.callingcard",
185 "application/vnd.ll.landmark",
186 "application/vnd.ll.clothing",
187 "application/vnd.ll.primitive",
188 "application/vnd.ll.notecard",
189 "application/vnd.ll.folder",
190 "application/vnd.ll.rootfolder",
191 "application/vnd.ll.lsltext",
192 "application/vnd.ll.lslbyte",
193 "image/tga",
194 "application/vnd.ll.bodypart",
195 "application/vnd.ll.trashfolder",
196 "application/vnd.ll.snapshotfolder",
197 "application/vnd.ll.lostandfoundfolder",
198 "audio/x-wav",
199 "image/tga",
200 "image/jpeg",
201 "application/vnd.ll.animation",
202 "application/vnd.ll.gesture",
203 "application/x-metaverse-simstate",
204 "application/vnd.ll.favoritefolder",
205 "application/vnd.ll.link",
206 "application/vnd.ll.linkfolder",
207 "application/vnd.ll.currentoutfitfolder",
208 "application/vnd.ll.outfitfolder",
209 "application/vnd.ll.myoutfitsfolder"
210 };
211 for (int i=0;i<assettypes.Length;i++)
212 {
213 Assert.That(SLUtil.SLAssetTypeToContentType(assettypes[i]) == contenttypes[i], "Expecting {0} but got {1}", contenttypes[i], SLUtil.SLAssetTypeToContentType(assettypes[i]));
214 }
215
216 for (int i = 0; i < contenttypes.Length; i++)
217 {
218 if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18)
219 {
220 Assert.That(contenttypes[i] == "image/tga");
221 }
222 else
223 {
224 Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i],
225 "Expecting {0} but got {1}", assettypes[i],
226 SLUtil.ContentTypeToSLAssetType(contenttypes[i]));
227 }
228 }
229
230 }
173 } 231 }
174} 232}