RegionSettingsSerializerTests.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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
  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. </RegionSettings>";
  80. private RegionSettings m_rs;
  81. [SetUp]
  82. public void Setup()
  83. {
  84. m_rs = new RegionSettings();
  85. m_rs.AgentLimit = 17;
  86. m_rs.AllowDamage = true;
  87. m_rs.AllowLandJoinDivide = true;
  88. m_rs.AllowLandResell = true;
  89. m_rs.BlockFly = true;
  90. m_rs.BlockShowInSearch = true;
  91. m_rs.BlockTerraform = true;
  92. m_rs.DisableCollisions = true;
  93. m_rs.DisablePhysics = true;
  94. m_rs.DisableScripts = true;
  95. m_rs.Elevation1NW = 15.9;
  96. m_rs.Elevation1NE = 45.3;
  97. m_rs.Elevation1SE = 49;
  98. m_rs.Elevation1SW = 1.9;
  99. m_rs.Elevation2NW = 4.5;
  100. m_rs.Elevation2NE = 19.2;
  101. m_rs.Elevation2SE = 9.2;
  102. m_rs.Elevation2SW = 2.1;
  103. m_rs.FixedSun = true;
  104. m_rs.SunPosition = 12.0;
  105. m_rs.ObjectBonus = 1.4;
  106. m_rs.RestrictPushing = true;
  107. m_rs.TerrainLowerLimit = 0.4;
  108. m_rs.TerrainRaiseLimit = 17.9;
  109. m_rs.TerrainTexture1 = UUID.Parse("00000000-0000-0000-0000-000000000020");
  110. m_rs.TerrainTexture2 = UUID.Parse("00000000-0000-0000-0000-000000000040");
  111. m_rs.TerrainTexture3 = UUID.Parse("00000000-0000-0000-0000-000000000060");
  112. m_rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080");
  113. m_rs.UseEstateSun = true;
  114. m_rs.WaterHeight = 23;
  115. }
  116. [Test]
  117. public void TestRegionSettingsDeserialize()
  118. {
  119. TestHelpers.InMethod();
  120. // log4net.Config.XmlConfigurator.Configure();
  121. RegionSettings deserRs = RegionSettingsSerializer.Deserialize(m_serializedRs);
  122. Assert.That(deserRs, Is.Not.Null);
  123. Assert.That(deserRs.TerrainTexture2, Is.EqualTo(m_rs.TerrainTexture2));
  124. Assert.That(deserRs.DisablePhysics, Is.EqualTo(m_rs.DisablePhysics));
  125. Assert.That(deserRs.TerrainLowerLimit, Is.EqualTo(m_rs.TerrainLowerLimit));
  126. }
  127. }
  128. }