diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs new file mode 100644 index 0000000..a886e33 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs | |||
@@ -0,0 +1,114 @@ | |||
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 NUnit.Framework; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Tests.Common; | ||
34 | using OpenSim.Tests.Common.Mock; | ||
35 | |||
36 | namespace OpenSim.Region.CoreModules.World.Land.Tests | ||
37 | { | ||
38 | public class LandManagementModuleTests | ||
39 | { | ||
40 | [Test] | ||
41 | public void TestAddLandObject() | ||
42 | { | ||
43 | TestHelpers.InMethod(); | ||
44 | // TestHelpers.EnableLogging(); | ||
45 | |||
46 | UUID userId = TestHelpers.ParseTail(0x1); | ||
47 | |||
48 | LandManagementModule lmm = new LandManagementModule(); | ||
49 | Scene scene = new SceneHelpers().SetupScene(); | ||
50 | SceneHelpers.SetupSceneModules(scene, lmm); | ||
51 | |||
52 | ILandObject lo = new LandObject(userId, false, scene); | ||
53 | lo.LandData.Name = "lo1"; | ||
54 | lo.SetLandBitmap( | ||
55 | lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | ||
56 | lo = lmm.AddLandObject(lo); | ||
57 | |||
58 | // TODO: Should add asserts to check that land object was added properly. | ||
59 | |||
60 | // At the moment, this test just makes sure that we can't add a land object that overlaps the areas that | ||
61 | // the first still holds. | ||
62 | ILandObject lo2 = new LandObject(userId, false, scene); | ||
63 | lo2.SetLandBitmap( | ||
64 | lo2.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | ||
65 | lo2.LandData.Name = "lo2"; | ||
66 | lo2 = lmm.AddLandObject(lo2); | ||
67 | |||
68 | { | ||
69 | ILandObject loAtCoord = lmm.GetLandObject(0, 0); | ||
70 | Assert.That(loAtCoord.LandData.LocalID, Is.EqualTo(lo.LandData.LocalID)); | ||
71 | Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(lo.LandData.GlobalID)); | ||
72 | } | ||
73 | |||
74 | { | ||
75 | ILandObject loAtCoord = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1)); | ||
76 | Assert.That(loAtCoord.LandData.LocalID, Is.EqualTo(lo.LandData.LocalID)); | ||
77 | Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(lo.LandData.GlobalID)); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | [Test] | ||
82 | public void TestSubdivide() | ||
83 | { | ||
84 | TestHelpers.InMethod(); | ||
85 | // TestHelpers.EnableLogging(); | ||
86 | |||
87 | UUID userId = TestHelpers.ParseTail(0x1); | ||
88 | |||
89 | LandManagementModule lmm = new LandManagementModule(); | ||
90 | Scene scene = new SceneHelpers().SetupScene(); | ||
91 | SceneHelpers.SetupSceneModules(scene, lmm); | ||
92 | |||
93 | ILandObject lo = new LandObject(userId, false, scene); | ||
94 | lo.LandData.Name = "lo1"; | ||
95 | lo.SetLandBitmap( | ||
96 | lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | ||
97 | lo = lmm.AddLandObject(lo); | ||
98 | |||
99 | lmm.Subdivide(0, 0, LandManagementModule.LandUnit, LandManagementModule.LandUnit, userId); | ||
100 | |||
101 | { | ||
102 | ILandObject loAtCoord = lmm.GetLandObject(0, 0); | ||
103 | Assert.That(loAtCoord.LandData.LocalID, Is.Not.EqualTo(lo.LandData.LocalID)); | ||
104 | Assert.That(loAtCoord.LandData.GlobalID, Is.Not.EqualTo(lo.LandData.GlobalID)); | ||
105 | } | ||
106 | |||
107 | { | ||
108 | ILandObject loAtCoord = lmm.GetLandObject(LandManagementModule.LandUnit, LandManagementModule.LandUnit); | ||
109 | Assert.That(loAtCoord.LandData.LocalID, Is.EqualTo(lo.LandData.LocalID)); | ||
110 | Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(lo.LandData.GlobalID)); | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | } \ No newline at end of file | ||