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