diff options
author | Justin Clark-Casey (justincc) | 2010-09-21 01:04:08 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-09-21 01:04:08 +0100 |
commit | 51207c24a03b2f5741a886b1d5daaac8d2231c93 (patch) | |
tree | 360c993fafd29a32cc132e8c62d390ccdab9e01e /OpenSim/Framework/Tests/MundaneFrameworkTests.cs | |
parent | Improve the explanative text of migration failures (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-51207c24a03b2f5741a886b1d5daaac8d2231c93.zip opensim-SC_OLD-51207c24a03b2f5741a886b1d5daaac8d2231c93.tar.gz opensim-SC_OLD-51207c24a03b2f5741a886b1d5daaac8d2231c93.tar.bz2 opensim-SC_OLD-51207c24a03b2f5741a886b1d5daaac8d2231c93.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Framework/Tests/MundaneFrameworkTests.cs')
-rw-r--r-- | OpenSim/Framework/Tests/MundaneFrameworkTests.cs | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs index e2e08c0..04be083 100644 --- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs +++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs | |||
@@ -29,12 +29,19 @@ using NUnit.Framework; | |||
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenMetaverse.StructuredData; | 31 | using OpenMetaverse.StructuredData; |
32 | using System; | ||
33 | using System.Globalization; | ||
34 | using System.Threading; | ||
32 | 35 | ||
33 | namespace OpenSim.Framework.Tests | 36 | namespace OpenSim.Framework.Tests |
34 | { | 37 | { |
35 | [TestFixture] | 38 | [TestFixture] |
36 | public class MundaneFrameworkTests | 39 | public class MundaneFrameworkTests |
37 | { | 40 | { |
41 | private bool m_RegionSettingsOnSaveEventFired; | ||
42 | private bool m_RegionLightShareDataOnSaveEventFired; | ||
43 | |||
44 | |||
38 | [Test] | 45 | [Test] |
39 | public void ChildAgentDataUpdate01() | 46 | public void ChildAgentDataUpdate01() |
40 | { | 47 | { |
@@ -124,8 +131,181 @@ namespace OpenSim.Framework.Tests | |||
124 | Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed"); | 131 | Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed"); |
125 | 132 | ||
126 | } | 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 | } | ||
127 | 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 | } | ||
128 | 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 | |||
129 | } | 309 | } |
130 | } | 310 | } |
131 | 311 | ||