BasicEstateTest.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  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. private 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>().Scramble(originalSettings);
  151. // Saving settings.
  152. db.StoreEstateSettings(originalSettings);
  153. // Loading settings to another instance variable.
  154. EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
  155. // Checking that loaded values are correct.
  156. Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
  157. }
  158. [Test]
  159. public void T020_EstateSettingsManagerList()
  160. {
  161. // Letting estate store generate rows to database for us
  162. EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
  163. originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 };
  164. // Saving settings.
  165. db.StoreEstateSettings(originalSettings);
  166. // Loading settings to another instance variable.
  167. EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
  168. Assert.AreEqual(2, loadedSettings.EstateManagers.Length);
  169. Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]);
  170. Assert.AreEqual(MANAGER_ID_2, loadedSettings.EstateManagers[1]);
  171. }
  172. [Test]
  173. public void T021_EstateSettingsUserList()
  174. {
  175. // Letting estate store generate rows to database for us
  176. EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
  177. originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 };
  178. // Saving settings.
  179. db.StoreEstateSettings(originalSettings);
  180. // Loading settings to another instance variable.
  181. EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
  182. Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
  183. Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]);
  184. Assert.AreEqual(USER_ID_2, loadedSettings.EstateAccess[1]);
  185. }
  186. [Test]
  187. public void T022_EstateSettingsGroupList()
  188. {
  189. // Letting estate store generate rows to database for us
  190. EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
  191. originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 };
  192. // Saving settings.
  193. db.StoreEstateSettings(originalSettings);
  194. // Loading settings to another instance variable.
  195. EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
  196. Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
  197. Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]);
  198. Assert.AreEqual(GROUP_ID_2, loadedSettings.EstateGroups[1]);
  199. }
  200. [Test]
  201. public void T022_EstateSettingsBanList()
  202. {
  203. // Letting estate store generate rows to database for us
  204. EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
  205. EstateBan estateBan1 = new EstateBan();
  206. estateBan1.BannedUserID = DataTestUtil.UUID_MIN;
  207. EstateBan estateBan2 = new EstateBan();
  208. estateBan2.BannedUserID = DataTestUtil.UUID_MAX;
  209. originalSettings.EstateBans = new EstateBan[] { estateBan1, estateBan2 };
  210. // Saving settings.
  211. db.StoreEstateSettings(originalSettings);
  212. // Loading settings to another instance variable.
  213. EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
  214. Assert.AreEqual(2, loadedSettings.EstateBans.Length);
  215. Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID);
  216. Assert.AreEqual(DataTestUtil.UUID_MAX, loadedSettings.EstateBans[1].BannedUserID);
  217. }
  218. #endregion
  219. #region Parametrizable Test Implementations
  220. private void EstateSettingsSimpleStorage(
  221. UUID regionId,
  222. string estateName,
  223. uint parentEstateID,
  224. float billableFactor,
  225. int pricePerMeter,
  226. int redirectGridX,
  227. int redirectGridY,
  228. bool useGlobalTime,
  229. bool fixedSun,
  230. double sunPosition,
  231. bool allowVoice,
  232. bool allowDirectTeleport,
  233. bool resetHomeOnTeleport,
  234. bool denyAnonymous,
  235. bool denyIdentified,
  236. bool denyTransacted,
  237. bool denyMinors,
  238. bool abuseEmailToEstateOwner,
  239. bool blockDwell,
  240. bool estateSkipScripts,
  241. bool taxFree,
  242. bool publicAccess,
  243. string abuseEmail,
  244. UUID estateOwner
  245. )
  246. {
  247. // Letting estate store generate rows to database for us
  248. EstateSettings originalSettings = db.LoadEstateSettings(regionId);
  249. SetEstateSettings(
  250. originalSettings,
  251. estateName,
  252. parentEstateID,
  253. billableFactor,
  254. pricePerMeter,
  255. redirectGridX,
  256. redirectGridY,
  257. useGlobalTime,
  258. fixedSun,
  259. sunPosition,
  260. allowVoice,
  261. allowDirectTeleport,
  262. resetHomeOnTeleport,
  263. denyAnonymous,
  264. denyIdentified,
  265. denyTransacted,
  266. denyMinors,
  267. abuseEmailToEstateOwner,
  268. blockDwell,
  269. estateSkipScripts,
  270. taxFree,
  271. publicAccess,
  272. abuseEmail,
  273. estateOwner
  274. );
  275. originalSettings.EstateName = estateName;
  276. originalSettings.ParentEstateID = parentEstateID;
  277. originalSettings.BillableFactor = billableFactor;
  278. originalSettings.PricePerMeter = pricePerMeter;
  279. originalSettings.RedirectGridX = redirectGridX;
  280. originalSettings.RedirectGridY = redirectGridY;
  281. originalSettings.UseGlobalTime = useGlobalTime;
  282. originalSettings.FixedSun = fixedSun;
  283. originalSettings.SunPosition = sunPosition;
  284. originalSettings.AllowVoice = allowVoice;
  285. originalSettings.AllowDirectTeleport = allowDirectTeleport;
  286. originalSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
  287. originalSettings.DenyAnonymous = denyAnonymous;
  288. originalSettings.DenyIdentified = denyIdentified;
  289. originalSettings.DenyTransacted = denyTransacted;
  290. originalSettings.DenyMinors = denyMinors;
  291. originalSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
  292. originalSettings.BlockDwell = blockDwell;
  293. originalSettings.EstateSkipScripts = estateSkipScripts;
  294. originalSettings.TaxFree = taxFree;
  295. originalSettings.PublicAccess = publicAccess;
  296. originalSettings.AbuseEmail = abuseEmail;
  297. originalSettings.EstateOwner = estateOwner;
  298. // Saving settings.
  299. db.StoreEstateSettings(originalSettings);
  300. // Loading settings to another instance variable.
  301. EstateSettings loadedSettings = db.LoadEstateSettings(regionId);
  302. // Checking that loaded values are correct.
  303. ValidateEstateSettings(
  304. loadedSettings,
  305. estateName,
  306. parentEstateID,
  307. billableFactor,
  308. pricePerMeter,
  309. redirectGridX,
  310. redirectGridY,
  311. useGlobalTime,
  312. fixedSun,
  313. sunPosition,
  314. allowVoice,
  315. allowDirectTeleport,
  316. resetHomeOnTeleport,
  317. denyAnonymous,
  318. denyIdentified,
  319. denyTransacted,
  320. denyMinors,
  321. abuseEmailToEstateOwner,
  322. blockDwell,
  323. estateSkipScripts,
  324. taxFree,
  325. publicAccess,
  326. abuseEmail,
  327. estateOwner
  328. );
  329. }
  330. #endregion
  331. #region EstateSetting Initialization and Validation Methods
  332. private void SetEstateSettings(
  333. EstateSettings estateSettings,
  334. string estateName,
  335. uint parentEstateID,
  336. float billableFactor,
  337. int pricePerMeter,
  338. int redirectGridX,
  339. int redirectGridY,
  340. bool useGlobalTime,
  341. bool fixedSun,
  342. double sunPosition,
  343. bool allowVoice,
  344. bool allowDirectTeleport,
  345. bool resetHomeOnTeleport,
  346. bool denyAnonymous,
  347. bool denyIdentified,
  348. bool denyTransacted,
  349. bool denyMinors,
  350. bool abuseEmailToEstateOwner,
  351. bool blockDwell,
  352. bool estateSkipScripts,
  353. bool taxFree,
  354. bool publicAccess,
  355. string abuseEmail,
  356. UUID estateOwner
  357. )
  358. {
  359. estateSettings.EstateName = estateName;
  360. estateSettings.ParentEstateID = parentEstateID;
  361. estateSettings.BillableFactor = billableFactor;
  362. estateSettings.PricePerMeter = pricePerMeter;
  363. estateSettings.RedirectGridX = redirectGridX;
  364. estateSettings.RedirectGridY = redirectGridY;
  365. estateSettings.UseGlobalTime = useGlobalTime;
  366. estateSettings.FixedSun = fixedSun;
  367. estateSettings.SunPosition = sunPosition;
  368. estateSettings.AllowVoice = allowVoice;
  369. estateSettings.AllowDirectTeleport = allowDirectTeleport;
  370. estateSettings.ResetHomeOnTeleport = resetHomeOnTeleport;
  371. estateSettings.DenyAnonymous = denyAnonymous;
  372. estateSettings.DenyIdentified = denyIdentified;
  373. estateSettings.DenyTransacted = denyTransacted;
  374. estateSettings.DenyMinors = denyMinors;
  375. estateSettings.AbuseEmailToEstateOwner = abuseEmailToEstateOwner;
  376. estateSettings.BlockDwell = blockDwell;
  377. estateSettings.EstateSkipScripts = estateSkipScripts;
  378. estateSettings.TaxFree = taxFree;
  379. estateSettings.PublicAccess = publicAccess;
  380. estateSettings.AbuseEmail = abuseEmail;
  381. estateSettings.EstateOwner = estateOwner;
  382. }
  383. private void ValidateEstateSettings(
  384. EstateSettings estateSettings,
  385. string estateName,
  386. uint parentEstateID,
  387. float billableFactor,
  388. int pricePerMeter,
  389. int redirectGridX,
  390. int redirectGridY,
  391. bool useGlobalTime,
  392. bool fixedSun,
  393. double sunPosition,
  394. bool allowVoice,
  395. bool allowDirectTeleport,
  396. bool resetHomeOnTeleport,
  397. bool denyAnonymous,
  398. bool denyIdentified,
  399. bool denyTransacted,
  400. bool denyMinors,
  401. bool abuseEmailToEstateOwner,
  402. bool blockDwell,
  403. bool estateSkipScripts,
  404. bool taxFree,
  405. bool publicAccess,
  406. string abuseEmail,
  407. UUID estateOwner
  408. )
  409. {
  410. Assert.AreEqual(estateName, estateSettings.EstateName);
  411. Assert.AreEqual(parentEstateID, estateSettings.ParentEstateID);
  412. DataTestUtil.AssertFloatEqualsWithTolerance(billableFactor, estateSettings.BillableFactor);
  413. Assert.AreEqual(pricePerMeter, estateSettings.PricePerMeter);
  414. Assert.AreEqual(redirectGridX, estateSettings.RedirectGridX);
  415. Assert.AreEqual(redirectGridY, estateSettings.RedirectGridY);
  416. Assert.AreEqual(useGlobalTime, estateSettings.UseGlobalTime);
  417. Assert.AreEqual(fixedSun, estateSettings.FixedSun);
  418. DataTestUtil.AssertDoubleEqualsWithTolerance(sunPosition, estateSettings.SunPosition);
  419. Assert.AreEqual(allowVoice, estateSettings.AllowVoice);
  420. Assert.AreEqual(allowDirectTeleport, estateSettings.AllowDirectTeleport);
  421. Assert.AreEqual(resetHomeOnTeleport, estateSettings.ResetHomeOnTeleport);
  422. Assert.AreEqual(denyAnonymous, estateSettings.DenyAnonymous);
  423. Assert.AreEqual(denyIdentified, estateSettings.DenyIdentified);
  424. Assert.AreEqual(denyTransacted, estateSettings.DenyTransacted);
  425. Assert.AreEqual(denyMinors, estateSettings.DenyMinors);
  426. Assert.AreEqual(abuseEmailToEstateOwner, estateSettings.AbuseEmailToEstateOwner);
  427. Assert.AreEqual(blockDwell, estateSettings.BlockDwell);
  428. Assert.AreEqual(estateSkipScripts, estateSettings.EstateSkipScripts);
  429. Assert.AreEqual(taxFree, estateSettings.TaxFree);
  430. Assert.AreEqual(publicAccess, estateSettings.PublicAccess);
  431. Assert.AreEqual(abuseEmail, estateSettings.AbuseEmail);
  432. Assert.AreEqual(estateOwner, estateSettings.EstateOwner);
  433. }
  434. #endregion
  435. }
  436. }