30 using NUnit.Framework;
32 using OpenSim.Framework;
33 using OpenSim.Region.Framework.Interfaces;
34 using OpenSim.Tests.Common;
37 using System.Reflection;
38 using System.Data.Common;
41 using MySql.Data.MySqlClient;
42 using OpenSim.Data.MySQL;
44 using Mono.Data.Sqlite;
45 using OpenSim.Data.SQLite;
47 namespace OpenSim.Data.Tests
49 [TestFixture(Description =
"Estate store tests (SQLite)")]
54 [TestFixture(Description =
"Estate store tests (MySQL)")]
59 public class EstateTests<TConn, TEstateStore> : BasicDataServiceTest<TConn, TEstateStore>
60 where TConn : DbConnection, new()
65 public static UUID REGION_ID =
new UUID(
"250d214e-1c7e-4f9b-a488-87c5e53feed7");
67 public static UUID USER_ID_1 =
new UUID(
"250d214e-1c7e-4f9b-a488-87c5e53feed1");
68 public static UUID USER_ID_2 =
new UUID(
"250d214e-1c7e-4f9b-a488-87c5e53feed2");
70 public static UUID MANAGER_ID_1 =
new UUID(
"250d214e-1c7e-4f9b-a488-87c5e53feed3");
71 public static UUID MANAGER_ID_2 =
new UUID(
"250d214e-1c7e-4f9b-a488-87c5e53feed4");
73 public static UUID GROUP_ID_1 =
new UUID(
"250d214e-1c7e-4f9b-a488-87c5e53feed5");
74 public static UUID GROUP_ID_2 =
new UUID(
"250d214e-1c7e-4f9b-a488-87c5e53feed6");
80 db.Initialise(m_connStr);
83 private void ClearDB()
94 ResetMigrations(
"EstateStore");
102 TestHelpers.InMethod();
104 EstateSettingsSimpleStorage(
135 TestHelpers.InMethod();
137 EstateSettingsSimpleStorage(
140 DataTestUtil.UNSIGNED_INTEGER_MAX,
141 DataTestUtil.FLOAT_MAX,
142 DataTestUtil.INTEGER_MAX,
143 DataTestUtil.INTEGER_MAX,
144 DataTestUtil.INTEGER_MAX,
145 DataTestUtil.BOOLEAN_MAX,
146 DataTestUtil.BOOLEAN_MAX,
147 DataTestUtil.DOUBLE_MAX,
148 DataTestUtil.BOOLEAN_MAX,
149 DataTestUtil.BOOLEAN_MAX,
150 DataTestUtil.BOOLEAN_MAX,
151 DataTestUtil.BOOLEAN_MAX,
152 DataTestUtil.BOOLEAN_MAX,
153 DataTestUtil.BOOLEAN_MAX,
154 DataTestUtil.BOOLEAN_MAX,
155 DataTestUtil.BOOLEAN_MAX,
156 DataTestUtil.BOOLEAN_MAX,
157 DataTestUtil.BOOLEAN_MAX,
158 DataTestUtil.BOOLEAN_MAX,
159 DataTestUtil.BOOLEAN_MAX,
160 DataTestUtil.STRING_MAX(255),
168 TestHelpers.InMethod();
170 EstateSettingsSimpleStorage(
173 DataTestUtil.UNSIGNED_INTEGER_MIN,
174 DataTestUtil.FLOAT_ACCURATE,
175 DataTestUtil.INTEGER_MIN,
176 DataTestUtil.INTEGER_MIN,
177 DataTestUtil.INTEGER_MIN,
178 DataTestUtil.BOOLEAN_MIN,
179 DataTestUtil.BOOLEAN_MIN,
180 DataTestUtil.DOUBLE_ACCURATE,
181 DataTestUtil.BOOLEAN_MIN,
182 DataTestUtil.BOOLEAN_MIN,
183 DataTestUtil.BOOLEAN_MIN,
184 DataTestUtil.BOOLEAN_MIN,
185 DataTestUtil.BOOLEAN_MIN,
186 DataTestUtil.BOOLEAN_MIN,
187 DataTestUtil.BOOLEAN_MIN,
188 DataTestUtil.BOOLEAN_MIN,
189 DataTestUtil.BOOLEAN_MIN,
190 DataTestUtil.BOOLEAN_MIN,
191 DataTestUtil.BOOLEAN_MIN,
192 DataTestUtil.BOOLEAN_MIN,
193 DataTestUtil.STRING_MAX(1),
201 TestHelpers.InMethod();
204 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID,
true);
205 new PropertyScrambler<EstateSettings>()
206 .DontScramble(x=>x.EstateID)
207 .Scramble(originalSettings);
210 db.StoreEstateSettings(originalSettings);
213 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID,
true);
216 Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
222 TestHelpers.InMethod();
225 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID,
true);
227 originalSettings.EstateManagers =
new UUID[] { MANAGER_ID_1, MANAGER_ID_2 };
230 db.StoreEstateSettings(originalSettings);
233 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID,
true);
235 Assert.AreEqual(2, loadedSettings.EstateManagers.Length);
236 Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]);
237 Assert.AreEqual(MANAGER_ID_2, loadedSettings.EstateManagers[1]);
243 TestHelpers.InMethod();
246 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID,
true);
248 originalSettings.EstateAccess =
new UUID[] { USER_ID_1, USER_ID_2 };
251 db.StoreEstateSettings(originalSettings);
254 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID,
true);
256 Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
257 Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]);
258 Assert.AreEqual(USER_ID_2, loadedSettings.EstateAccess[1]);
264 TestHelpers.InMethod();
267 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID,
true);
269 originalSettings.EstateGroups =
new UUID[] { GROUP_ID_1, GROUP_ID_2 };
272 db.StoreEstateSettings(originalSettings);
275 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID,
true);
277 Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
278 Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]);
279 Assert.AreEqual(GROUP_ID_2, loadedSettings.EstateGroups[1]);
285 TestHelpers.InMethod();
288 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID,
true);
291 estateBan1.BannedUserID = DataTestUtil.UUID_MIN;
294 estateBan2.BannedUserID = DataTestUtil.UUID_MAX;
296 originalSettings.EstateBans =
new EstateBan[] { estateBan1, estateBan2 };
299 db.StoreEstateSettings(originalSettings);
302 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID,
true);
304 Assert.AreEqual(2, loadedSettings.EstateBans.Length);
305 Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID);
307 Assert.AreEqual(DataTestUtil.UUID_MAX, loadedSettings.EstateBans[1].BannedUserID);
313 #region Parametrizable Test Implementations
315 private void EstateSettingsSimpleStorage(
319 float billableFactor,
327 bool allowDirectTeleport,
328 bool resetHomeOnTeleport,
333 bool abuseEmailToEstateOwner,
335 bool estateSkipScripts,
344 EstateSettings originalSettings = db.LoadEstateSettings(regionId,
true);
346 SetEstateSettings(originalSettings,
363 abuseEmailToEstateOwner,
373 db.StoreEstateSettings(originalSettings);
376 EstateSettings loadedSettings = db.LoadEstateSettings(regionId,
true);
379 ValidateEstateSettings(loadedSettings,
396 abuseEmailToEstateOwner,
409 #region EstateSetting Initialization and Validation Methods
411 private void SetEstateSettings(
415 float billableFactor,
423 bool allowDirectTeleport,
424 bool resetHomeOnTeleport,
429 bool abuseEmailToEstateOwner,
431 bool estateSkipScripts,
438 estateSettings.EstateName = estateName;
439 estateSettings.ParentEstateID = parentEstateID;
440 estateSettings.BillableFactor = billableFactor;
441 estateSettings.PricePerMeter = pricePerMeter;
442 estateSettings.RedirectGridX = redirectGridX;
443 estateSettings.RedirectGridY = redirectGridY;
444 estateSettings.UseGlobalTime = useGlobalTime;
445 estateSettings.FixedSun = fixedSun;
446 estateSettings.SunPosition = sunPosition;
447 estateSettings.AllowVoice = allowVoice;
448 estateSettings.AllowDirectTeleport = allowDirectTeleport;
449 estateSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
450 estateSettings.DenyAnonymous = denyAnonymous;
451 estateSettings.DenyIdentified = denyIdentified;
452 estateSettings.DenyTransacted = denyTransacted;
453 estateSettings.DenyMinors = denyMinors;
454 estateSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
455 estateSettings.BlockDwell = blockDwell;
456 estateSettings.EstateSkipScripts = estateSkipScripts;
457 estateSettings.TaxFree = taxFree;
458 estateSettings.PublicAccess = publicAccess;
459 estateSettings.AbuseEmail = abuseEmail;
460 estateSettings.EstateOwner = estateOwner;
463 private void ValidateEstateSettings(
467 float billableFactor,
475 bool allowDirectTeleport,
476 bool resetHomeOnTeleport,
481 bool abuseEmailToEstateOwner,
483 bool estateSkipScripts,
490 Assert.AreEqual(estateName, estateSettings.EstateName);
491 Assert.AreEqual(parentEstateID, estateSettings.ParentEstateID);
493 DataTestUtil.AssertFloatEqualsWithTolerance(billableFactor, estateSettings.BillableFactor);
495 Assert.AreEqual(pricePerMeter, estateSettings.PricePerMeter);
496 Assert.AreEqual(redirectGridX, estateSettings.RedirectGridX);
497 Assert.AreEqual(redirectGridY, estateSettings.RedirectGridY);
498 Assert.AreEqual(useGlobalTime, estateSettings.UseGlobalTime);
499 Assert.AreEqual(fixedSun, estateSettings.FixedSun);
501 DataTestUtil.AssertDoubleEqualsWithTolerance(sunPosition, estateSettings.SunPosition);
503 Assert.AreEqual(allowVoice, estateSettings.AllowVoice);
504 Assert.AreEqual(allowDirectTeleport, estateSettings.AllowDirectTeleport);
505 Assert.AreEqual(resetHomeOnTeleport, estateSettings.ResetHomeOnTeleport);
506 Assert.AreEqual(denyAnonymous, estateSettings.DenyAnonymous);
507 Assert.AreEqual(denyIdentified, estateSettings.DenyIdentified);
508 Assert.AreEqual(denyTransacted, estateSettings.DenyTransacted);
509 Assert.AreEqual(denyMinors, estateSettings.DenyMinors);
510 Assert.AreEqual(abuseEmailToEstateOwner, estateSettings.AbuseEmailToEstateOwner);
511 Assert.AreEqual(blockDwell, estateSettings.BlockDwell);
512 Assert.AreEqual(estateSkipScripts, estateSettings.EstateSkipScripts);
513 Assert.AreEqual(taxFree, estateSettings.TaxFree);
514 Assert.AreEqual(publicAccess, estateSettings.PublicAccess);
515 Assert.AreEqual(abuseEmail, estateSettings.AbuseEmail);
516 Assert.AreEqual(estateOwner, estateSettings.EstateOwner);
void T022_EstateSettingsGroupList()
void T020_EstateSettingsManagerList()
override void InitService(object service)
To be overridden in derived classes. Do whatever init with the m_service, like setting the conn strin...
void T021_EstateSettingsUserList()
static string STRING_MAX(int length)
Shared constants and methods for database unit tests.
const uint UNSIGNED_INTEGER_MIN
void T012_EstateSettingsRandomStorage()
void T011_EstateSettingsSimpleStorage_MaximumParameterSet()
void T022_EstateSettingsBanList()
void T012_EstateSettingsSimpleStorage_AccurateParameterSet()
void T010_EstateSettingsSimpleStorage_MinimumParameterSet()