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