RegionSettingsSerializerTests.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 System.Collections.Generic;
  29. using OpenMetaverse;
  30. using OpenMetaverse.StructuredData;
  31. using NUnit.Framework;
  32. using OpenSim.Framework;
  33. using OpenSim.Framework.Serialization.External;
  34. using OpenSim.Tests.Common;
  35. namespace OpenSim.Framework.Serialization.Tests
  36. {
  37. [TestFixture]
  38. public class RegionSettingsSerializerTests : OpenSimTestCase
  39. {
  40. private string m_serializedRs = @"<?xml version=""1.0"" encoding=""utf-16""?>
  41. <RegionSettings>
  42. <General>
  43. <AllowDamage>True</AllowDamage>
  44. <AllowLandResell>True</AllowLandResell>
  45. <AllowLandJoinDivide>True</AllowLandJoinDivide>
  46. <BlockFly>True</BlockFly>
  47. <BlockLandShowInSearch>True</BlockLandShowInSearch>
  48. <BlockTerraform>True</BlockTerraform>
  49. <DisableCollisions>True</DisableCollisions>
  50. <DisablePhysics>True</DisablePhysics>
  51. <DisableScripts>True</DisableScripts>
  52. <MaturityRating>1</MaturityRating>
  53. <RestrictPushing>True</RestrictPushing>
  54. <AgentLimit>40</AgentLimit>
  55. <ObjectBonus>1.4</ObjectBonus>
  56. </General>
  57. <GroundTextures>
  58. <Texture1>00000000-0000-0000-0000-000000000020</Texture1>
  59. <Texture2>00000000-0000-0000-0000-000000000040</Texture2>
  60. <Texture3>00000000-0000-0000-0000-000000000060</Texture3>
  61. <Texture4>00000000-0000-0000-0000-000000000080</Texture4>
  62. <ElevationLowSW>1.9</ElevationLowSW>
  63. <ElevationLowNW>15.9</ElevationLowNW>
  64. <ElevationLowSE>49</ElevationLowSE>
  65. <ElevationLowNE>45.3</ElevationLowNE>
  66. <ElevationHighSW>2.1</ElevationHighSW>
  67. <ElevationHighNW>4.5</ElevationHighNW>
  68. <ElevationHighSE>9.2</ElevationHighSE>
  69. <ElevationHighNE>19.2</ElevationHighNE>
  70. </GroundTextures>
  71. <Terrain>
  72. <WaterHeight>23</WaterHeight>
  73. <TerrainRaiseLimit>17.9</TerrainRaiseLimit>
  74. <TerrainLowerLimit>0.4</TerrainLowerLimit>
  75. <UseEstateSun>True</UseEstateSun>
  76. <FixedSun>true</FixedSun>
  77. <SunPosition>12</SunPosition>
  78. </Terrain>
  79. <Telehub>
  80. <TelehubObject>00000000-0000-0000-0000-111111111111</TelehubObject>
  81. <SpawnPoint>1,-2,0.33</SpawnPoint>
  82. </Telehub>
  83. </RegionSettings>";
  84. private RegionSettings m_rs;
  85. [SetUp]
  86. public void Setup()
  87. {
  88. m_rs = new RegionSettings();
  89. m_rs.AgentLimit = 17;
  90. m_rs.AllowDamage = true;
  91. m_rs.AllowLandJoinDivide = true;
  92. m_rs.AllowLandResell = true;
  93. m_rs.BlockFly = true;
  94. m_rs.BlockShowInSearch = true;
  95. m_rs.BlockTerraform = true;
  96. m_rs.DisableCollisions = true;
  97. m_rs.DisablePhysics = true;
  98. m_rs.DisableScripts = true;
  99. m_rs.Elevation1NW = 15.9;
  100. m_rs.Elevation1NE = 45.3;
  101. m_rs.Elevation1SE = 49;
  102. m_rs.Elevation1SW = 1.9;
  103. m_rs.Elevation2NW = 4.5;
  104. m_rs.Elevation2NE = 19.2;
  105. m_rs.Elevation2SE = 9.2;
  106. m_rs.Elevation2SW = 2.1;
  107. m_rs.FixedSun = true;
  108. m_rs.SunPosition = 12.0;
  109. m_rs.ObjectBonus = 1.4;
  110. m_rs.RestrictPushing = true;
  111. m_rs.TerrainLowerLimit = 0.4;
  112. m_rs.TerrainRaiseLimit = 17.9;
  113. m_rs.TerrainTexture1 = UUID.Parse("00000000-0000-0000-0000-000000000020");
  114. m_rs.TerrainTexture2 = UUID.Parse("00000000-0000-0000-0000-000000000040");
  115. m_rs.TerrainTexture3 = UUID.Parse("00000000-0000-0000-0000-000000000060");
  116. m_rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080");
  117. m_rs.UseEstateSun = true;
  118. m_rs.WaterHeight = 23;
  119. m_rs.TelehubObject = UUID.Parse("00000000-0000-0000-0000-111111111111");
  120. m_rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33"));
  121. }
  122. [Test]
  123. public void TestRegionSettingsDeserialize()
  124. {
  125. TestHelpers.InMethod();
  126. // log4net.Config.XmlConfigurator.Configure();
  127. RegionSettings deserRs = RegionSettingsSerializer.Deserialize(m_serializedRs, out ViewerEnvironment dummy, new EstateSettings());
  128. Assert.That(deserRs, Is.Not.Null);
  129. Assert.That(deserRs.TerrainTexture2, Is.EqualTo(m_rs.TerrainTexture2));
  130. Assert.That(deserRs.DisablePhysics, Is.EqualTo(m_rs.DisablePhysics));
  131. Assert.That(deserRs.TerrainLowerLimit, Is.EqualTo(m_rs.TerrainLowerLimit));
  132. Assert.That(deserRs.TelehubObject, Is.EqualTo(m_rs.TelehubObject));
  133. Assert.That(deserRs.SpawnPoints()[0].ToString(), Is.EqualTo(m_rs.SpawnPoints()[0].ToString()));
  134. }
  135. }
  136. }