29 using System.Collections.Generic;
31 using System.Reflection;
34 using NUnit.Framework;
36 using OpenSim.Framework;
37 using OpenSim.Services.Interfaces;
39 using OpenSim.Services.Connectors;
41 namespace Robust.Tests
55 GridRegion r1 = CreateRegion(
"Test Region 1", 1000, 1000);
56 GridRegion r2 = CreateRegion(
"Test Region 2", 1001, 1000);
57 GridRegion r3 = CreateRegion(
"Test Region 3", 1005, 1000);
59 string msg = m_Connector.RegisterRegion(UUID.Zero, r1);
60 Assert.AreEqual(msg, string.Empty,
"Region 1 failed to register");
62 msg = m_Connector.RegisterRegion(UUID.Zero, r2);
63 Assert.AreEqual(msg, string.Empty,
"Region 2 failed to register");
65 msg = m_Connector.RegisterRegion(UUID.Zero, r3);
66 Assert.AreEqual(msg, string.Empty,
"Region 3 failed to register");
69 success = m_Connector.DeregisterRegion(r3.RegionID);
70 Assert.AreEqual(success,
true,
"Region 3 failed to deregister");
72 msg = m_Connector.RegisterRegion(UUID.Zero, r3);
73 Assert.AreEqual(msg, string.Empty,
"Region 3 failed to re-register");
75 List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID);
76 Assert.AreNotEqual(regions, null,
"GetNeighbours of region 1 failed");
77 Assert.AreEqual(regions.Count, 1,
"Region 1 should have 1 neighbor");
78 Assert.AreEqual(regions[0].RegionName,
"Test Region 2",
"Region 1 has the wrong neighbor");
80 GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID);
81 Assert.AreNotEqual(region, null,
"GetRegionByUUID for region 2 failed");
82 Assert.AreEqual(region.RegionName,
"Test Region 2",
"GetRegionByUUID of region 2 returned wrong region");
84 region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random());
85 Assert.AreEqual(region, null,
"Region with randon id should not exist");
87 region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName);
88 Assert.AreNotEqual(region, null,
"GetRegionByUUID for region 3 failed");
89 Assert.AreEqual(region.RegionName,
"Test Region 3",
"GetRegionByUUID of region 3 returned wrong region");
91 region = m_Connector.GetRegionByName(UUID.Zero,
"Foo");
92 Assert.AreEqual(region, null,
"Region Foo should not exist");
94 regions = m_Connector.GetRegionsByName(UUID.Zero,
"Test", 10);
95 Assert.AreNotEqual(regions, null,
"GetRegionsByName failed");
96 Assert.AreEqual(regions.Count, 3,
"GetRegionsByName should return 3");
98 regions = m_Connector.GetRegionRange(UUID.Zero,
99 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002),
100 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002) );
101 Assert.AreNotEqual(regions, null,
"GetRegionRange failed");
102 Assert.AreEqual(regions.Count, 2,
"GetRegionRange should return 2");
104 regions = m_Connector.GetRegionRange(UUID.Zero,
105 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950),
106 (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950) );
107 Assert.AreNotEqual(regions, null,
"GetRegionRange (bis) failed");
108 Assert.AreEqual(regions.Count, 0,
"GetRegionRange (bis) should return 0");
111 success = m_Connector.DeregisterRegion(r1.RegionID);
112 Assert.AreEqual(success,
true,
"Region 1 failed to deregister");
114 success = m_Connector.DeregisterRegion(r2.RegionID);
115 Assert.AreEqual(success,
true,
"Region 2 failed to deregister");
117 success = m_Connector.DeregisterRegion(r3.RegionID);
118 Assert.AreEqual(success,
true,
"Region 3 failed to deregister");
121 private static GridRegion CreateRegion(
string name, uint xcell, uint ycell)
124 region.RegionName = name;
125 region.RegionID = UUID.Random();
126 region.ExternalHostName =
"127.0.0.1";
127 region.HttpPort = 9000;
128 region.InternalEndPoint =
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(
"0.0.0.0"), 9000);
OpenSim.Services.Interfaces.GridRegion GridRegion