BasicEstateTest.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. using System;
  28. using log4net.Config;
  29. using NUnit.Framework;
  30. using NUnit.Framework.SyntaxHelpers;
  31. using OpenMetaverse;
  32. using OpenSim.Framework;
  33. using OpenSim.Region.Framework.Interfaces;
  34. using System.Text;
  35. using log4net;
  36. using System.Reflection;
  37. namespace OpenSim.Data.Tests
  38. {
  39. public class BasicEstateTest
  40. {
  41. public IEstateDataStore db;
  42. public IRegionDataStore regionDb;
  43. public static UUID REGION_ID = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed7");
  44. public static UUID USER_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed1");
  45. public static UUID USER_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed2");
  46. public static UUID MANAGER_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed3");
  47. public static UUID MANAGER_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed4");
  48. public static UUID GROUP_ID_1 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed5");
  49. public static UUID GROUP_ID_2 = new UUID("250d214e-1c7e-4f9b-a488-87c5e53feed6");
  50. public void SuperInit()
  51. {
  52. OpenSim.Tests.Common.TestLogging.LogToConsole();
  53. }
  54. #region 0Tests
  55. [Test]
  56. public void T010_EstateSettingsSimpleStorage_MinimumParameterSet()
  57. {
  58. EstateSettingsSimpleStorage(
  59. REGION_ID,
  60. DataTestUtil.STRING_MIN,
  61. DataTestUtil.UNSIGNED_INTEGER_MIN,
  62. DataTestUtil.FLOAT_MIN,
  63. DataTestUtil.INTEGER_MIN,
  64. DataTestUtil.INTEGER_MIN,
  65. DataTestUtil.INTEGER_MIN,
  66. DataTestUtil.BOOLEAN_MIN,
  67. DataTestUtil.BOOLEAN_MIN,
  68. DataTestUtil.DOUBLE_MIN,
  69. DataTestUtil.BOOLEAN_MIN,
  70. DataTestUtil.BOOLEAN_MIN,
  71. DataTestUtil.BOOLEAN_MIN,
  72. DataTestUtil.BOOLEAN_MIN,
  73. DataTestUtil.BOOLEAN_MIN,
  74. DataTestUtil.BOOLEAN_MIN,
  75. DataTestUtil.BOOLEAN_MIN,
  76. DataTestUtil.BOOLEAN_MIN,
  77. DataTestUtil.BOOLEAN_MIN,
  78. DataTestUtil.BOOLEAN_MIN,
  79. DataTestUtil.BOOLEAN_MIN,
  80. DataTestUtil.BOOLEAN_MIN,
  81. DataTestUtil.STRING_MIN,
  82. DataTestUtil.UUID_MIN
  83. );
  84. }
  85. [Test]
  86. public void T011_EstateSettingsSimpleStorage_MaximumParameterSet()
  87. {
  88. EstateSettingsSimpleStorage(
  89. REGION_ID,
  90. DataTestUtil.STRING_MAX(64),
  91. DataTestUtil.UNSIGNED_INTEGER_MAX,
  92. DataTestUtil.FLOAT_MAX,
  93. DataTestUtil.INTEGER_MAX,
  94. DataTestUtil.INTEGER_MAX,
  95. DataTestUtil.INTEGER_MAX,
  96. DataTestUtil.BOOLEAN_MAX,
  97. DataTestUtil.BOOLEAN_MAX,
  98. DataTestUtil.DOUBLE_MAX,
  99. DataTestUtil.BOOLEAN_MAX,
  100. DataTestUtil.BOOLEAN_MAX,
  101. DataTestUtil.BOOLEAN_MAX,
  102. DataTestUtil.BOOLEAN_MAX,
  103. DataTestUtil.BOOLEAN_MAX,
  104. DataTestUtil.BOOLEAN_MAX,
  105. DataTestUtil.BOOLEAN_MAX,
  106. DataTestUtil.BOOLEAN_MAX,
  107. DataTestUtil.BOOLEAN_MAX,
  108. DataTestUtil.BOOLEAN_MAX,
  109. DataTestUtil.BOOLEAN_MAX,
  110. DataTestUtil.BOOLEAN_MAX,
  111. DataTestUtil.STRING_MAX(255),
  112. DataTestUtil.UUID_MAX
  113. );
  114. }
  115. [Test]
  116. public void T012_EstateSettingsSimpleStorage_AccurateParameterSet()
  117. {
  118. EstateSettingsSimpleStorage(
  119. REGION_ID,
  120. DataTestUtil.STRING_MAX(1),
  121. DataTestUtil.UNSIGNED_INTEGER_MIN,
  122. DataTestUtil.FLOAT_ACCURATE,
  123. DataTestUtil.INTEGER_MIN,
  124. DataTestUtil.INTEGER_MIN,
  125. DataTestUtil.INTEGER_MIN,
  126. DataTestUtil.BOOLEAN_MIN,
  127. DataTestUtil.BOOLEAN_MIN,
  128. DataTestUtil.DOUBLE_ACCURATE,
  129. DataTestUtil.BOOLEAN_MIN,
  130. DataTestUtil.BOOLEAN_MIN,
  131. DataTestUtil.BOOLEAN_MIN,
  132. DataTestUtil.BOOLEAN_MIN,
  133. DataTestUtil.BOOLEAN_MIN,
  134. DataTestUtil.BOOLEAN_MIN,
  135. DataTestUtil.BOOLEAN_MIN,
  136. DataTestUtil.BOOLEAN_MIN,
  137. DataTestUtil.BOOLEAN_MIN,
  138. DataTestUtil.BOOLEAN_MIN,
  139. DataTestUtil.BOOLEAN_MIN,
  140. DataTestUtil.BOOLEAN_MIN,
  141. DataTestUtil.STRING_MAX(1),
  142. DataTestUtil.UUID_MIN
  143. );
  144. }
  145. [Test]
  146. public void T012_EstateSettingsRandomStorage()
  147. {
  148. // Letting estate store generate rows to database for us
  149. EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
  150. new PropertyScrambler<EstateSettings>()
  151. .DontScramble(x=>x.EstateID)
  152. .Scramble(originalSettings);
  153. // Saving settings.
  154. db.StoreEstateSettings(originalSettings);
  155. // Loading settings to another instance variable.
  156. EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
  157. // Checking that loaded values are correct.
  158. Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
  159. }
  160. [Test]
  161. public void T020_EstateSettingsManagerList()
  162. {
  163. // Letting estate store generate rows to database for us
  164. EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
  165. originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 };
  166. // Saving settings.
  167. db.StoreEstateSettings(originalSettings);
  168. // Loading settings to another instance variable.
  169. EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
  170. Assert.AreEqual(2, loadedSettings.EstateManagers.Length);
  171. Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]);
  172. Assert.AreEqual(MANAGER_ID_2, loadedSettings.EstateManagers[1]);
  173. }
  174. [Test]
  175. public void T021_EstateSettingsUserList()
  176. {
  177. // Letting estate store generate rows to database for us
  178. EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
  179. originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 };
  180. // Saving settings.
  181. db.StoreEstateSettings(originalSettings);
  182. // Loading settings to another instance variable.
  183. EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
  184. Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
  185. Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]);
  186. Assert.AreEqual(USER_ID_2, loadedSettings.EstateAccess[1]);
  187. }
  188. [Test]
  189. public void T022_EstateSettingsGroupList()
  190. {
  191. // Letting estate store generate rows to database for us
  192. EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
  193. originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 };
  194. // Saving settings.
  195. db.StoreEstateSettings(originalSettings);
  196. // Loading settings to another instance variable.
  197. EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
  198. Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
  199. Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]);
  200. Assert.AreEqual(GROUP_ID_2, loadedSettings.EstateGroups[1]);
  201. }
  202. [Test]
  203. public void T022_EstateSettingsBanList()
  204. {
  205. // Letting estate store generate rows to database for us
  206. EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
  207. EstateBan estateBan1 = new EstateBan();
  208. estateBan1.BannedUserID = DataTestUtil.UUID_MIN;
  209. EstateBan estateBan2 = new EstateBan();
  210. estateBan2.BannedUserID = DataTestUtil.UUID_MAX;
  211. originalSettings.EstateBans = new EstateBan[] { estateBan1, estateBan2 };
  212. // Saving settings.
  213. db.StoreEstateSettings(originalSettings);
  214. // Loading settings to another instance variable.
  215. EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
  216. Assert.AreEqual(2, loadedSettings.EstateBans.Length);
  217. Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID);
  218. Assert.AreEqual(DataTestUtil.UUID_MAX, loadedSettings.EstateBans[1].BannedUserID);
  219. }
  220. #endregion
  221. #region Parametrizable Test Implementations
  222. private void EstateSettingsSimpleStorage(
  223. UUID regionId,
  224. string estateName,
  225. uint parentEstateID,
  226. float billableFactor,
  227. int pricePerMeter,
  228. int redirectGridX,
  229. int redirectGridY,
  230. bool useGlobalTime,
  231. bool fixedSun,
  232. double sunPosition,
  233. bool allowVoice,
  234. bool allowDirectTeleport,
  235. bool resetHomeOnTeleport,
  236. bool denyAnonymous,
  237. bool denyIdentified,
  238. bool denyTransacted,
  239. bool denyMinors,
  240. bool abuseEmailToEstateOwner,
  241. bool blockDwell,
  242. bool estateSkipScripts,
  243. bool taxFree,
  244. bool publicAccess,
  245. string abuseEmail,
  246. UUID estateOwner
  247. )
  248. {
  249. // Letting estate store generate rows to database for us
  250. EstateSettings originalSettings = db.LoadEstateSettings(regionId);
  251. SetEstateSettings(
  252. originalSettings,
  253. estateName,
  254. parentEstateID,
  255. billableFactor,
  256. pricePerMeter,
  257. redirectGridX,
  258. redirectGridY,
  259. useGlobalTime,
  260. fixedSun,
  261. sunPosition,
  262. allowVoice,
  263. allowDirectTeleport,
  264. resetHomeOnTeleport,
  265. denyAnonymous,
  266. denyIdentified,
  267. denyTransacted,
  268. denyMinors,
  269. abuseEmailToEstateOwner,
  270. blockDwell,
  271. estateSkipScripts,
  272. taxFree,
  273. publicAccess,
  274. abuseEmail,
  275. estateOwner
  276. );
  277. originalSettings.EstateName = estateName;
  278. originalSettings.ParentEstateID = parentEstateID;
  279. originalSettings.BillableFactor = billableFactor;
  280. originalSettings.PricePerMeter = pricePerMeter;
  281. originalSettings.RedirectGridX = redirectGridX;
  282. originalSettings.RedirectGridY = redirectGridY;
  283. originalSettings.UseGlobalTime = useGlobalTime;
  284. originalSettings.FixedSun = fixedSun;
  285. originalSettings.SunPosition = sunPosition;
  286. originalSettings.AllowVoice = allowVoice;
  287. originalSettings.AllowDirectTeleport = allowDirectTeleport;
  288. originalSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
  289. originalSettings.DenyAnonymous = denyAnonymous;
  290. originalSettings.DenyIdentified = denyIdentified;
  291. originalSettings.DenyTransacted = denyTransacted;
  292. originalSettings.DenyMinors = denyMinors;
  293. originalSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
  294. originalSettings.BlockDwell = blockDwell;
  295. originalSettings.EstateSkipScripts = estateSkipScripts;
  296. originalSettings.TaxFree = taxFree;
  297. originalSettings.PublicAccess = publicAccess;
  298. originalSettings.AbuseEmail = abuseEmail;
  299. originalSettings.EstateOwner = estateOwner;
  300. // Saving settings.
  301. db.StoreEstateSettings(originalSettings);
  302. // Loading settings to another instance variable.
  303. EstateSettings loadedSettings = db.LoadEstateSettings(regionId);
  304. // Checking that loaded values are correct.
  305. ValidateEstateSettings(
  306. loadedSettings,
  307. estateName,
  308. parentEstateID,
  309. billableFactor,
  310. pricePerMeter,
  311. redirectGridX,
  312. redirectGridY,
  313. useGlobalTime,
  314. fixedSun,
  315. sunPosition,
  316. allowVoice,
  317. allowDirectTeleport,
  318. resetHomeOnTeleport,
  319. denyAnonymous,
  320. denyIdentified,
  321. denyTransacted,
  322. denyMinors,
  323. abuseEmailToEstateOwner,
  324. blockDwell,
  325. estateSkipScripts,
  326. taxFree,
  327. publicAccess,
  328. abuseEmail,
  329. estateOwner
  330. );
  331. }
  332. #endregion
  333. #region EstateSetting Initialization and Validation Methods
  334. private void SetEstateSettings(
  335. EstateSettings estateSettings,
  336. string estateName,
  337. uint parentEstateID,
  338. float billableFactor,
  339. int pricePerMeter,
  340. int redirectGridX,
  341. int redirectGridY,
  342. bool useGlobalTime,
  343. bool fixedSun,
  344. double sunPosition,
  345. bool allowVoice,
  346. bool allowDirectTeleport,
  347. bool resetHomeOnTeleport,
  348. bool denyAnonymous,
  349. bool denyIdentified,
  350. bool denyTransacted,
  351. bool denyMinors,
  352. bool abuseEmailToEstateOwner,
  353. bool blockDwell,
  354. bool estateSkipScripts,
  355. bool taxFree,
  356. bool publicAccess,
  357. string abuseEmail,
  358. UUID estateOwner
  359. )
  360. {
  361. estateSettings.EstateName = estateName;
  362. estateSettings.ParentEstateID = parentEstateID;
  363. estateSettings.BillableFactor = billableFactor;
  364. estateSettings.PricePerMeter = pricePerMeter;
  365. estateSettings.RedirectGridX = redirectGridX;
  366. estateSettings.RedirectGridY = redirectGridY;
  367. estateSettings.UseGlobalTime = useGlobalTime;
  368. estateSettings.FixedSun = fixedSun;
  369. estateSettings.SunPosition = sunPosition;
  370. estateSettings.AllowVoice = allowVoice;
  371. estateSettings.AllowDirectTeleport = allowDirectTeleport;
  372. estateSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
  373. estateSettings.DenyAnonymous = denyAnonymous;
  374. estateSettings.DenyIdentified = denyIdentified;
  375. estateSettings.DenyTransacted = denyTransacted;
  376. estateSettings.DenyMinors = denyMinors;
  377. estateSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
  378. estateSettings.BlockDwell = blockDwell;
  379. estateSettings.EstateSkipScripts = estateSkipScripts;
  380. estateSettings.TaxFree = taxFree;
  381. estateSettings.PublicAccess = publicAccess;
  382. estateSettings.AbuseEmail = abuseEmail;
  383. estateSettings.EstateOwner = estateOwner;
  384. }
  385. private void ValidateEstateSettings(
  386. EstateSettings estateSettings,
  387. string estateName,
  388. uint parentEstateID,
  389. float billableFactor,
  390. int pricePerMeter,
  391. int redirectGridX,
  392. int redirectGridY,
  393. bool useGlobalTime,
  394. bool fixedSun,
  395. double sunPosition,
  396. bool allowVoice,
  397. bool allowDirectTeleport,
  398. bool resetHomeOnTeleport,
  399. bool denyAnonymous,
  400. bool denyIdentified,
  401. bool denyTransacted,
  402. bool denyMinors,
  403. bool abuseEmailToEstateOwner,
  404. bool blockDwell,
  405. bool estateSkipScripts,
  406. bool taxFree,
  407. bool publicAccess,
  408. string abuseEmail,
  409. UUID estateOwner
  410. )
  411. {
  412. Assert.AreEqual(estateName, estateSettings.EstateName);
  413. Assert.AreEqual(parentEstateID, estateSettings.ParentEstateID);
  414. DataTestUtil.AssertFloatEqualsWithTolerance(billableFactor, estateSettings.BillableFactor);
  415. Assert.AreEqual(pricePerMeter, estateSettings.PricePerMeter);
  416. Assert.AreEqual(redirectGridX, estateSettings.RedirectGridX);
  417. Assert.AreEqual(redirectGridY, estateSettings.RedirectGridY);
  418. Assert.AreEqual(useGlobalTime, estateSettings.UseGlobalTime);
  419. Assert.AreEqual(fixedSun, estateSettings.FixedSun);
  420. DataTestUtil.AssertDoubleEqualsWithTolerance(sunPosition, estateSettings.SunPosition);
  421. Assert.AreEqual(allowVoice, estateSettings.AllowVoice);
  422. Assert.AreEqual(allowDirectTeleport, estateSettings.AllowDirectTeleport);
  423. Assert.AreEqual(resetHomeOnTeleport, estateSettings.ResetHomeOnTeleport);
  424. Assert.AreEqual(denyAnonymous, estateSettings.DenyAnonymous);
  425. Assert.AreEqual(denyIdentified, estateSettings.DenyIdentified);
  426. Assert.AreEqual(denyTransacted, estateSettings.DenyTransacted);
  427. Assert.AreEqual(denyMinors, estateSettings.DenyMinors);
  428. Assert.AreEqual(abuseEmailToEstateOwner, estateSettings.AbuseEmailToEstateOwner);
  429. Assert.AreEqual(blockDwell, estateSettings.BlockDwell);
  430. Assert.AreEqual(estateSkipScripts, estateSettings.EstateSkipScripts);
  431. Assert.AreEqual(taxFree, estateSettings.TaxFree);
  432. Assert.AreEqual(publicAccess, estateSettings.PublicAccess);
  433. Assert.AreEqual(abuseEmail, estateSettings.AbuseEmail);
  434. Assert.AreEqual(estateOwner, estateSettings.EstateOwner);
  435. }
  436. #endregion
  437. }
  438. }