28 using NUnit.Framework;
29 using OpenSim.Framework;
31 using OpenMetaverse.StructuredData;
33 using System.Globalization;
34 using System.Threading;
35 using OpenSim.Tests.Common;
37 namespace OpenSim.Framework.Tests
42 private bool m_RegionSettingsOnSaveEventFired;
43 private bool m_RegionLightShareDataOnSaveEventFired;
51 Assert.IsFalse(cadu.alwaysrun,
"Default is false");
57 UUID AgentId1 = UUID.Random();
58 UUID SessionId1 = UUID.Random();
59 uint CircuitCode1 = uint.MinValue;
60 Vector3 Size1 = Vector3.UnitZ;
61 Vector3 Position1 = Vector3.UnitX;
62 Vector3 LeftAxis1 = Vector3.UnitY;
63 Vector3 UpAxis1 = Vector3.UnitZ;
64 Vector3 AtAxis1 = Vector3.UnitX;
66 ulong RegionHandle1 = ulong.MinValue;
67 byte[] Throttles1 =
new byte[] {0, 1, 0};
69 Vector3 Velocity1 = Vector3.Zero;
72 bool ChangedGrid1 =
false;
73 Vector3 Center1 = Vector3.Zero;
76 position1.AgentID = AgentId1;
77 position1.SessionID = SessionId1;
78 position1.CircuitCode = CircuitCode1;
79 position1.Size = Size1;
80 position1.Position = Position1;
81 position1.LeftAxis = LeftAxis1;
82 position1.UpAxis = UpAxis1;
83 position1.AtAxis = AtAxis1;
84 position1.RegionHandle = RegionHandle1;
85 position1.Throttles = Throttles1;
86 position1.Velocity = Velocity1;
88 position1.ChangedGrid = ChangedGrid1;
89 position1.Center = Center1;
92 cadu.AgentID = AgentId1.Guid;
93 cadu.ActiveGroupID = UUID.Zero.Guid;
94 cadu.throttles = Throttles1;
95 cadu.drawdistance = Far1;
96 cadu.Position = Position1;
97 cadu.Velocity = Velocity1;
98 cadu.regionHandle = RegionHandle1;
99 cadu.cameraPosition = Center1;
100 cadu.AVHeight = Size1.Z;
103 position2.CopyFrom(cadu, position1.SessionID);
106 position2.AgentID == position1.AgentID
107 && position2.Size == position1.Size
108 && position2.Position == position1.Position
109 && position2.Velocity == position1.Velocity
110 && position2.Center == position1.Center
111 && position2.RegionHandle == position1.RegionHandle
112 && position2.Far == position1.Far
114 ,
"Copy From ChildAgentDataUpdate failed");
118 Assert.IsFalse(position2.AgentID == position1.AgentID,
"Test Error, position2 should be a blank uninitialized AgentPosition");
120 position2.Unpack(position1.Pack(ctx), null, ctx);
122 Assert.IsTrue(position2.AgentID == position1.AgentID,
"Agent ID didn't unpack the same way it packed");
123 Assert.IsTrue(position2.Position == position1.Position,
"Position didn't unpack the same way it packed");
124 Assert.IsTrue(position2.Velocity == position1.Velocity,
"Velocity didn't unpack the same way it packed");
125 Assert.IsTrue(position2.SessionID == position1.SessionID,
"SessionID didn't unpack the same way it packed");
126 Assert.IsTrue(position2.CircuitCode == position1.CircuitCode,
"CircuitCode didn't unpack the same way it packed");
127 Assert.IsTrue(position2.LeftAxis == position1.LeftAxis,
"LeftAxis didn't unpack the same way it packed");
128 Assert.IsTrue(position2.UpAxis == position1.UpAxis,
"UpAxis didn't unpack the same way it packed");
129 Assert.IsTrue(position2.AtAxis == position1.AtAxis,
"AtAxis didn't unpack the same way it packed");
130 Assert.IsTrue(position2.RegionHandle == position1.RegionHandle,
"RegionHandle didn't unpack the same way it packed");
131 Assert.IsTrue(position2.ChangedGrid == position1.ChangedGrid,
"ChangedGrid didn't unpack the same way it packed");
132 Assert.IsTrue(position2.Center == position1.Center,
"Center didn't unpack the same way it packed");
133 Assert.IsTrue(position2.Size == position1.Size,
"Size didn't unpack the same way it packed");
141 settings.OnSave += RegionSaveFired;
143 settings.OnSave -= RegionSaveFired;
150 Assert.That(m_RegionSettingsOnSaveEventFired,
"RegionSettings Save Event didn't Fire");
155 m_RegionSettingsOnSaveEventFired =
true;
162 Assert.That(b1.ID == UUID.Zero,
"void constructor should create an inventory item with ID = UUID.Zero");
163 Assert.That(b1.Owner == UUID.Zero,
"void constructor should create an inventory item with Owner = UUID.Zero");
165 UUID ItemID = UUID.Random();
166 UUID OwnerID = UUID.Random();
169 Assert.That(b2.ID == ItemID,
"ID constructor should create an inventory item with ID = ItemID");
170 Assert.That(b2.Owner == UUID.Zero,
"ID constructor should create an inventory item with Owner = UUID.Zero");
173 Assert.That(b3.ID == ItemID,
"ID,OwnerID constructor should create an inventory item with ID = ItemID");
174 Assert.That(b3.Owner == OwnerID,
"ID,OwnerID constructor should create an inventory item with Owner = OwnerID");
182 assetMetadata.ContentType =
"image/jp2";
183 Assert.That(assetMetadata.Type == (sbyte)AssetType.Texture,
"Content type should be AssetType.Texture");
184 Assert.That(assetMetadata.ContentType ==
"image/jp2",
"Text of content type should be image/jp2");
185 UUID rndID = UUID.Random();
186 assetMetadata.ID = rndID.ToString();
187 Assert.That(assetMetadata.ID.ToLower() == rndID.ToString().ToLower(),
"assetMetadata.ID Setter/Getter not Consistent");
188 DateTime fixedTime = DateTime.Now;
189 assetMetadata.CreationDate = fixedTime;
196 rlsd.OnSave += RegionLightShareDataSaveFired;
198 rlsd.OnSave -= RegionLightShareDataSaveFired;
199 Assert.IsTrue(m_RegionLightShareDataOnSaveEventFired,
"OnSave Event Never Fired");
201 object o = rlsd.Clone();
203 Assert.IsTrue(rlsd.sceneGamma == dupe.sceneGamma,
"Memberwise Clone of RegionLightShareData failed");
207 m_RegionLightShareDataOnSaveEventFired =
true;
215 UUID bannedUserId = UUID.Random();
217 { BannedHostAddress = string.Empty,
218 BannedHostIPMask = string.Empty,
219 BannedHostNameMask = string.Empty,
220 BannedUserID = bannedUserId}
222 Assert.IsTrue(es.IsBanned(bannedUserId, 32),
"User Should be banned but is not.");
223 Assert.IsFalse(es.IsBanned(UUID.Zero, 32),
"User Should not be banned but is.");
225 es.RemoveBan(bannedUserId);
227 Assert.IsFalse(es.IsBanned(bannedUserId, 32),
"User Should not be banned but is.");
229 es.AddEstateManager(UUID.Zero);
231 es.AddEstateManager(bannedUserId);
232 Assert.IsTrue(es.IsEstateManagerOrOwner(bannedUserId),
"bannedUserId should be EstateManager but isn't.");
234 es.RemoveEstateManager(bannedUserId);
235 Assert.IsFalse(es.IsEstateManagerOrOwner(bannedUserId),
"bannedUserID is estateManager but shouldn't be");
237 Assert.IsFalse(es.HasAccess(bannedUserId),
"bannedUserID has access but shouldn't");
239 es.AddEstateUser(bannedUserId);
241 Assert.IsTrue(es.HasAccess(bannedUserId),
"bannedUserID doesn't have access but should");
242 es.RemoveEstateUser(bannedUserId);
244 es.AddEstateManager(bannedUserId);
246 Assert.IsTrue(es.HasAccess(bannedUserId),
"bannedUserID doesn't have access but should");
248 Assert.That(es.EstateGroups.Length == 0,
"No Estate Groups Added.. so the array should be 0 length");
250 es.AddEstateGroup(bannedUserId);
252 Assert.That(es.EstateGroups.Length == 1,
"1 Estate Groups Added.. so the array should be 1 length");
254 Assert.That(es.EstateGroups[0] == bannedUserId,
"User ID should be in EstateGroups");
261 UUID uuid1 = UUID.Random();
262 UUID uuid2 = UUID.Random();
265 Assert.That(fld.ID == uuid1,
"ID constructor failed to save value in ID field.");
268 Assert.That(fld.ID == uuid1,
"ID,Owner constructor failed to save value in ID field.");
269 Assert.That(fld.Owner == uuid2,
"ID,Owner constructor failed to save value in ID field.");
276 Assert.IsNotNull(abase.Metadata,
"void constructor of AssetBase should have created a MetaData element but didn't.");
277 UUID itemID = UUID.Random();
278 UUID creatorID = UUID.Random();
279 abase =
new AssetBase(itemID.ToString(),
"test item", (sbyte) AssetType.Texture, creatorID.ToString());
281 Assert.IsNotNull(abase.Metadata,
"string,string,sbyte,string constructor of AssetBase should have created a MetaData element but didn't.");
282 Assert.That(abase.ID == itemID.ToString(),
"string,string,sbyte,string constructor failed to set ID property");
283 Assert.That(abase.Metadata.CreatorID == creatorID.ToString(),
"string,string,sbyte,string constructor failed to set Creator ID");
286 abase =
new AssetBase(itemID.ToString(),
"test item", -1, creatorID.ToString());
287 Assert.IsNotNull(abase.Metadata,
"string,string,sbyte,string constructor of AssetBase with unknown type should have created a MetaData element but didn't.");
288 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");
291 metts.FullID = itemID;
292 metts.ID = string.Empty;
293 metts.Name =
"test item";
294 abase.Metadata = metts;
296 Assert.That(abase.ToString() == itemID.ToString(),
"ToString is overriden to be fullID.ToString()");
297 Assert.That(abase.ID == itemID.ToString(),
"ID should be MetaData.FullID.ToString() when string.empty or null is provided to the ID property");
303 CultureInfo ci =
new CultureInfo(
"en-US",
false);
304 Culture.SetCurrentCulture();
305 Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name,
"SetCurrentCulture failed to set thread culture to en-US");
void RegionSettingsTest01()
void CultureSetCultureTest01()
void ChildAgentDataUpdate01()
OpenSim.Framework.RegionSettings RegionSettings
void EstateSettingsMundateTests()
void AsssetBaseConstructorTest01()
void AssetMetaDataNonNullContentTypeTest01()
Asset class. All Assets are reference by this class or a class derived from this class ...
Inventory Item - contains all the properties associated with an individual inventory piece...
void RegionLightShareDataSaveFired(RegionLightShareData settings)
void InventoryFolderBaseConstructorTest01()
Replacement for ChildAgentDataUpdate. Used over RESTComms and LocalComms.
void AgentPositionTest01()
void RegionSaveFired(RegionSettings settings)
void InventoryItemBaseConstructorTest01()
void RegionLightShareDataCloneSaveTest01()