diff options
author | Mike Mazur | 2009-03-11 00:33:34 +0000 |
---|---|---|
committer | Mike Mazur | 2009-03-11 00:33:34 +0000 |
commit | 8606d7d126ea8fa2b7a1baae7acfc0836c6c16c5 (patch) | |
tree | 32a5eb7c149d2c2fcda3a27893fdffc6f41684f8 /OpenSim/Data/Tests/BasicGridTest.cs | |
parent | * Cleanup and CCC (Code Convention Conformance) (diff) | |
download | opensim-SC_OLD-8606d7d126ea8fa2b7a1baae7acfc0836c6c16c5.zip opensim-SC_OLD-8606d7d126ea8fa2b7a1baae7acfc0836c6c16c5.tar.gz opensim-SC_OLD-8606d7d126ea8fa2b7a1baae7acfc0836c6c16c5.tar.bz2 opensim-SC_OLD-8606d7d126ea8fa2b7a1baae7acfc0836c6c16c5.tar.xz |
Remove chained tests in BasicGridTest.cs.
It's good practice to isolate unit tests so their outcome (pass/fail)
does not depend on whether another test has been run/passed/failed. A
method is used to populate the DB independently for each test, and a
TearDown method cleans up the database after each test.
Also adding extra comment in C-style comment test.
Diffstat (limited to 'OpenSim/Data/Tests/BasicGridTest.cs')
-rw-r--r-- | OpenSim/Data/Tests/BasicGridTest.cs | 206 |
1 files changed, 88 insertions, 118 deletions
diff --git a/OpenSim/Data/Tests/BasicGridTest.cs b/OpenSim/Data/Tests/BasicGridTest.cs index 86c3115..b108c68 100644 --- a/OpenSim/Data/Tests/BasicGridTest.cs +++ b/OpenSim/Data/Tests/BasicGridTest.cs | |||
@@ -45,6 +45,15 @@ namespace OpenSim.Data.Tests | |||
45 | public UUID zero = UUID.Zero; | 45 | public UUID zero = UUID.Zero; |
46 | public static Random random; | 46 | public static Random random; |
47 | 47 | ||
48 | [TearDown] | ||
49 | public void removeAllRegions() | ||
50 | { | ||
51 | // Clean up all the regions. | ||
52 | foreach (RegionProfileData region in db.GetRegionsByName("", 100)) | ||
53 | { | ||
54 | db.DeleteProfile(region.Uuid.ToString()); | ||
55 | } | ||
56 | } | ||
48 | 57 | ||
49 | public void SuperInit() | 58 | public void SuperInit() |
50 | { | 59 | { |
@@ -62,6 +71,44 @@ namespace OpenSim.Data.Tests | |||
62 | random = new Random(); | 71 | random = new Random(); |
63 | } | 72 | } |
64 | 73 | ||
74 | protected RegionProfileData createRegion(UUID regionUUID, string regionName) | ||
75 | { | ||
76 | RegionProfileData reg = new RegionProfileData(); | ||
77 | reg.Uuid = regionUUID; | ||
78 | reg.RegionName = regionName; | ||
79 | reg.RegionHandle = (ulong) random.Next(); | ||
80 | reg.RegionLocX = (uint) random.Next(); | ||
81 | reg.RegionLocY = (uint) random.Next(); | ||
82 | reg.RegionLocZ = (uint) random.Next(); | ||
83 | reg.RegionSendKey = RandomName(); | ||
84 | reg.RegionRecvKey = RandomName(); | ||
85 | reg.RegionSecret = RandomName(); | ||
86 | reg.RegionOnline = false; | ||
87 | reg.ServerIP = RandomName(); | ||
88 | reg.ServerPort = (uint) random.Next(); | ||
89 | reg.ServerURI = RandomName(); | ||
90 | reg.ServerHttpPort = (uint) random.Next(); | ||
91 | reg.ServerRemotingPort = (uint) random.Next(); | ||
92 | reg.NorthOverrideHandle = (ulong) random.Next(); | ||
93 | reg.SouthOverrideHandle = (ulong) random.Next(); | ||
94 | reg.EastOverrideHandle = (ulong) random.Next(); | ||
95 | reg.WestOverrideHandle = (ulong) random.Next(); | ||
96 | reg.RegionDataURI = RandomName(); | ||
97 | reg.RegionAssetURI = RandomName(); | ||
98 | reg.RegionAssetSendKey = RandomName(); | ||
99 | reg.RegionAssetRecvKey = RandomName(); | ||
100 | reg.RegionUserURI = RandomName(); | ||
101 | reg.RegionUserSendKey = RandomName(); | ||
102 | reg.RegionUserRecvKey = RandomName(); | ||
103 | reg.RegionMapTextureID = UUID.Random(); | ||
104 | reg.Owner_uuid = UUID.Random(); | ||
105 | reg.OriginUUID = UUID.Random(); | ||
106 | |||
107 | db.AddProfile(reg); | ||
108 | |||
109 | return reg; | ||
110 | } | ||
111 | |||
65 | [Test] | 112 | [Test] |
66 | public void T001_LoadEmpty() | 113 | public void T001_LoadEmpty() |
67 | { | 114 | { |
@@ -78,137 +125,57 @@ namespace OpenSim.Data.Tests | |||
78 | } | 125 | } |
79 | 126 | ||
80 | [Test] | 127 | [Test] |
81 | public void T010_SimpleAddRetrieveProfile() | ||
82 | { | ||
83 | RegionProfileData reg = new RegionProfileData(); | ||
84 | reg.Uuid = region1; | ||
85 | reg.RegionName = "My new Region"; | ||
86 | reg.RegionHandle = (ulong) random.Next(); | ||
87 | reg.RegionLocX = 1000; | ||
88 | reg.RegionLocY = 1000; | ||
89 | reg.RegionLocZ = 0; | ||
90 | |||
91 | db.AddProfile(reg); | ||
92 | |||
93 | RegionProfileData retreg = db.GetProfileByUUID(region1); | ||
94 | |||
95 | Assert.That(retreg.RegionName, Is.EqualTo("My new Region")); | ||
96 | Assert.That(retreg.Uuid, Is.EqualTo(region1)); | ||
97 | } | ||
98 | |||
99 | [Test] | ||
100 | public void T011_AddRetrieveCompleteTest() | 128 | public void T011_AddRetrieveCompleteTest() |
101 | { | 129 | { |
102 | string regionname = "|<Goth@m Ci1y>|"; | 130 | RegionProfileData newreg = createRegion(region2, "|<Goth@m Ci1y>|"); |
103 | ulong regionhandle = (ulong) random.Next(); | ||
104 | uint regionlocx = (uint) random.Next(); | ||
105 | uint regionlocy = (uint) random.Next(); | ||
106 | uint regionlocz = (uint) random.Next(); | ||
107 | string regionsendkey = RandomName(); | ||
108 | string regionrecvkey = RandomName(); | ||
109 | string regionsecret = RandomName(); | ||
110 | bool regiononline = false; | ||
111 | string serverip = RandomName(); | ||
112 | uint serverport = (uint) random.Next(); | ||
113 | string serveruri = RandomName(); | ||
114 | uint serverhttpport = (uint) random.Next(); | ||
115 | uint serverremotingport = (uint) random.Next(); | ||
116 | ulong northovrhandle = (ulong) random.Next(); | ||
117 | ulong southovrhandle = (ulong) random.Next(); | ||
118 | ulong eastovrhandle = (ulong) random.Next(); | ||
119 | ulong westovrhandle = (ulong) random.Next(); | ||
120 | string regiondatauri = RandomName(); | ||
121 | string regionasseturi = RandomName(); | ||
122 | string regionassetsendkey = RandomName(); | ||
123 | string regionassetrcvkey = RandomName(); | ||
124 | string regionuseruri = RandomName(); | ||
125 | string regionusersendkey = RandomName(); | ||
126 | string regionuserrcvkey = RandomName(); | ||
127 | UUID regionmaptextureid = UUID.Random(); | ||
128 | UUID owner_uuid = UUID.Random(); | ||
129 | UUID originuuid = UUID.Random(); | ||
130 | |||
131 | |||
132 | RegionProfileData reg = new RegionProfileData(); | ||
133 | reg.Uuid = region2; | ||
134 | reg.RegionName = regionname; | ||
135 | reg.RegionHandle = regionhandle; | ||
136 | reg.RegionLocX = regionlocx; | ||
137 | reg.RegionLocY = regionlocy; | ||
138 | reg.RegionLocZ = regionlocz; | ||
139 | reg.RegionSendKey = regionsendkey; | ||
140 | reg.RegionRecvKey = regionrecvkey; | ||
141 | reg.RegionSecret = regionsecret; | ||
142 | reg.RegionOnline = regiononline; | ||
143 | reg.OriginUUID = originuuid; | ||
144 | reg.ServerIP = serverip; | ||
145 | reg.ServerPort = serverport; | ||
146 | reg.ServerURI = serveruri; | ||
147 | reg.ServerHttpPort = serverhttpport; | ||
148 | reg.ServerRemotingPort = serverremotingport; | ||
149 | reg.NorthOverrideHandle = northovrhandle; | ||
150 | reg.SouthOverrideHandle = southovrhandle; | ||
151 | reg.EastOverrideHandle = eastovrhandle; | ||
152 | reg.WestOverrideHandle = westovrhandle; | ||
153 | reg.RegionDataURI = regiondatauri; | ||
154 | reg.RegionAssetURI = regionasseturi; | ||
155 | reg.RegionAssetSendKey = regionassetsendkey; | ||
156 | reg.RegionAssetRecvKey = regionassetrcvkey; | ||
157 | reg.RegionUserURI = regionuseruri; | ||
158 | reg.RegionUserSendKey = regionusersendkey; | ||
159 | reg.RegionUserRecvKey = regionuserrcvkey; | ||
160 | reg.RegionMapTextureID = regionmaptextureid; | ||
161 | reg.Owner_uuid = owner_uuid; | ||
162 | reg.OriginUUID = originuuid; | ||
163 | |||
164 | db.AddProfile(reg); | ||
165 | |||
166 | RegionProfileData retreg = db.GetProfileByUUID(region2); | 131 | RegionProfileData retreg = db.GetProfileByUUID(region2); |
167 | 132 | ||
168 | Assert.That(retreg.RegionName, Is.EqualTo(regionname)); | 133 | Assert.That(retreg.RegionName, Is.EqualTo(newreg.RegionName)); |
169 | Assert.That(retreg.Uuid, Is.EqualTo(region2)); | 134 | Assert.That(retreg.Uuid, Is.EqualTo(region2)); |
170 | Assert.That(retreg.RegionHandle, Is.EqualTo(regionhandle)); | 135 | Assert.That(retreg.RegionHandle, Is.EqualTo(newreg.RegionHandle)); |
171 | Assert.That(retreg.RegionLocX, Is.EqualTo(regionlocx)); | 136 | Assert.That(retreg.RegionLocX, Is.EqualTo(newreg.RegionLocX)); |
172 | Assert.That(retreg.RegionLocY, Is.EqualTo(regionlocy)); | 137 | Assert.That(retreg.RegionLocY, Is.EqualTo(newreg.RegionLocY)); |
173 | Assert.That(retreg.RegionLocZ, Is.EqualTo(regionlocz)); | 138 | Assert.That(retreg.RegionLocZ, Is.EqualTo(newreg.RegionLocZ)); |
174 | Assert.That(retreg.RegionSendKey, Is.EqualTo(regionsendkey)); | 139 | Assert.That(retreg.RegionSendKey, Is.EqualTo(newreg.RegionSendKey)); |
175 | Assert.That(retreg.RegionRecvKey, Is.EqualTo(regionrecvkey)); | 140 | Assert.That(retreg.RegionRecvKey, Is.EqualTo(newreg.RegionRecvKey)); |
176 | Assert.That(retreg.RegionSecret, Is.EqualTo(regionsecret)); | 141 | Assert.That(retreg.RegionSecret, Is.EqualTo(newreg.RegionSecret)); |
177 | Assert.That(retreg.RegionOnline, Is.EqualTo(regiononline)); | 142 | Assert.That(retreg.RegionOnline, Is.EqualTo(newreg.RegionOnline)); |
178 | Assert.That(retreg.OriginUUID, Is.EqualTo(originuuid)); | 143 | Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID)); |
179 | Assert.That(retreg.ServerIP, Is.EqualTo(serverip)); | 144 | Assert.That(retreg.ServerIP, Is.EqualTo(newreg.ServerIP)); |
180 | Assert.That(retreg.ServerPort, Is.EqualTo(serverport)); | 145 | Assert.That(retreg.ServerPort, Is.EqualTo(newreg.ServerPort)); |
181 | Assert.That(retreg.ServerURI, Is.EqualTo(serveruri)); | 146 | Assert.That(retreg.ServerURI, Is.EqualTo(newreg.ServerURI)); |
182 | Assert.That(retreg.ServerHttpPort, Is.EqualTo(serverhttpport)); | 147 | Assert.That(retreg.ServerHttpPort, Is.EqualTo(newreg.ServerHttpPort)); |
183 | Assert.That(retreg.ServerRemotingPort, Is.EqualTo(serverremotingport)); | 148 | Assert.That(retreg.ServerRemotingPort, Is.EqualTo(newreg.ServerRemotingPort)); |
184 | Assert.That(retreg.NorthOverrideHandle, Is.EqualTo(northovrhandle)); | 149 | Assert.That(retreg.NorthOverrideHandle, Is.EqualTo(newreg.NorthOverrideHandle)); |
185 | Assert.That(retreg.SouthOverrideHandle, Is.EqualTo(southovrhandle)); | 150 | Assert.That(retreg.SouthOverrideHandle, Is.EqualTo(newreg.SouthOverrideHandle)); |
186 | Assert.That(retreg.EastOverrideHandle, Is.EqualTo(eastovrhandle)); | 151 | Assert.That(retreg.EastOverrideHandle, Is.EqualTo(newreg.EastOverrideHandle)); |
187 | Assert.That(retreg.WestOverrideHandle, Is.EqualTo(westovrhandle)); | 152 | Assert.That(retreg.WestOverrideHandle, Is.EqualTo(newreg.WestOverrideHandle)); |
188 | Assert.That(retreg.RegionDataURI, Is.EqualTo(regiondatauri)); | 153 | Assert.That(retreg.RegionDataURI, Is.EqualTo(newreg.RegionDataURI)); |
189 | Assert.That(retreg.RegionAssetURI, Is.EqualTo(regionasseturi)); | 154 | Assert.That(retreg.RegionAssetURI, Is.EqualTo(newreg.RegionAssetURI)); |
190 | Assert.That(retreg.RegionAssetSendKey, Is.EqualTo(regionassetsendkey)); | 155 | Assert.That(retreg.RegionAssetSendKey, Is.EqualTo(newreg.RegionAssetSendKey)); |
191 | Assert.That(retreg.RegionAssetRecvKey, Is.EqualTo(regionassetrcvkey)); | 156 | Assert.That(retreg.RegionAssetRecvKey, Is.EqualTo(newreg.RegionAssetRecvKey)); |
192 | Assert.That(retreg.RegionUserURI, Is.EqualTo(regionuseruri)); | 157 | Assert.That(retreg.RegionUserURI, Is.EqualTo(newreg.RegionUserURI)); |
193 | Assert.That(retreg.RegionUserSendKey, Is.EqualTo(regionusersendkey)); | 158 | Assert.That(retreg.RegionUserSendKey, Is.EqualTo(newreg.RegionUserSendKey)); |
194 | Assert.That(retreg.RegionUserRecvKey, Is.EqualTo(regionuserrcvkey)); | 159 | Assert.That(retreg.RegionUserRecvKey, Is.EqualTo(newreg.RegionUserRecvKey)); |
195 | Assert.That(retreg.RegionMapTextureID, Is.EqualTo(regionmaptextureid)); | 160 | Assert.That(retreg.RegionMapTextureID, Is.EqualTo(newreg.RegionMapTextureID)); |
196 | Assert.That(retreg.Owner_uuid, Is.EqualTo(owner_uuid)); | 161 | Assert.That(retreg.Owner_uuid, Is.EqualTo(newreg.Owner_uuid)); |
197 | Assert.That(retreg.OriginUUID, Is.EqualTo(originuuid)); | 162 | Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID)); |
198 | 163 | ||
199 | retreg = db.GetProfileByHandle(regionhandle); | 164 | retreg = db.GetProfileByHandle(newreg.RegionHandle); |
200 | Assert.That(retreg.Uuid, Is.EqualTo(region2)); | 165 | Assert.That(retreg.Uuid, Is.EqualTo(region2)); |
201 | 166 | ||
202 | retreg = db.GetProfileByString(regionname); | 167 | retreg = db.GetProfileByString(newreg.RegionName); |
203 | Assert.That(retreg.Uuid, Is.EqualTo(region2)); | 168 | Assert.That(retreg.Uuid, Is.EqualTo(region2)); |
204 | 169 | ||
205 | RegionProfileData[] retregs = db.GetProfilesInRange(regionlocx,regionlocy,regionlocx,regionlocy); | 170 | RegionProfileData[] retregs = db.GetProfilesInRange(newreg.RegionLocX,newreg.RegionLocY,newreg.RegionLocX,newreg.RegionLocY); |
206 | Assert.That(retregs[0].Uuid, Is.EqualTo(region2)); | 171 | Assert.That(retregs[0].Uuid, Is.EqualTo(region2)); |
207 | } | 172 | } |
208 | 173 | ||
209 | [Test] | 174 | [Test] |
210 | public void T012_DeleteProfile() | 175 | public void T012_DeleteProfile() |
211 | { | 176 | { |
177 | createRegion(region1, "doesn't matter"); | ||
178 | |||
212 | db.DeleteProfile(region1.ToString()); | 179 | db.DeleteProfile(region1.ToString()); |
213 | RegionProfileData retreg = db.GetProfileByUUID(region1); | 180 | RegionProfileData retreg = db.GetProfileByUUID(region1); |
214 | Assert.That(retreg,Is.Null); | 181 | Assert.That(retreg,Is.Null); |
@@ -217,6 +184,8 @@ namespace OpenSim.Data.Tests | |||
217 | [Test] | 184 | [Test] |
218 | public void T013_UpdateProfile() | 185 | public void T013_UpdateProfile() |
219 | { | 186 | { |
187 | createRegion(region2, "|<Goth@m Ci1y>|"); | ||
188 | |||
220 | RegionProfileData retreg = db.GetProfileByUUID(region2); | 189 | RegionProfileData retreg = db.GetProfileByUUID(region2); |
221 | retreg.regionName = "Gotham City"; | 190 | retreg.regionName = "Gotham City"; |
222 | 191 | ||
@@ -229,6 +198,8 @@ namespace OpenSim.Data.Tests | |||
229 | [Test] | 198 | [Test] |
230 | public void T014_RegionList() | 199 | public void T014_RegionList() |
231 | { | 200 | { |
201 | createRegion(region2, "Gotham City"); | ||
202 | |||
232 | RegionProfileData retreg = db.GetProfileByUUID(region2); | 203 | RegionProfileData retreg = db.GetProfileByUUID(region2); |
233 | retreg.RegionName = "Gotham Town"; | 204 | retreg.RegionName = "Gotham Town"; |
234 | retreg.Uuid = region1; | 205 | retreg.Uuid = region1; |
@@ -249,8 +220,7 @@ namespace OpenSim.Data.Tests | |||
249 | Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2)); | 220 | Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2)); |
250 | } | 221 | } |
251 | 222 | ||
252 | [Test] | 223 | protected static string RandomName() |
253 | public static string RandomName() | ||
254 | { | 224 | { |
255 | StringBuilder name = new StringBuilder(); | 225 | StringBuilder name = new StringBuilder(); |
256 | int size = random.Next(5,12); | 226 | int size = random.Next(5,12); |