diff options
author | Kunnis | 2009-08-15 10:54:48 -0500 |
---|---|---|
committer | Teravus Ovares (Dan Olivares) | 2009-08-16 14:17:29 -0400 |
commit | d2e5380cb2325ad42917c528c52a8ad42ec0176f (patch) | |
tree | 614ef74c8083db2afb1384b2acba0108e493b6c7 /OpenSim/Data/Tests | |
parent | * Modified SQLite/SQLiteInventoryStore.cs to not throw if the inventory row d... (diff) | |
download | opensim-SC_OLD-d2e5380cb2325ad42917c528c52a8ad42ec0176f.zip opensim-SC_OLD-d2e5380cb2325ad42917c528c52a8ad42ec0176f.tar.gz opensim-SC_OLD-d2e5380cb2325ad42917c528c52a8ad42ec0176f.tar.bz2 opensim-SC_OLD-d2e5380cb2325ad42917c528c52a8ad42ec0176f.tar.xz |
* Fixed MySQL/MySQLAssetData.cs to properly do updates * Removed an extra parameter from MySQL/MySQLInventoryData.cs * Fixed a bug in SQLite/SQLiteAssetData.cs that was causing a NRE when updating an asset. * Improved the BasicAssetTest.cs to do full create/update/get testing * Improved the BasicInventoryTest.cs to do full create/update/get of both a folder and an item * Moved the null ref tests to the start of the PropertyCompareConstraint.cs, so that it doesn't throw when passing in a null item
Diffstat (limited to 'OpenSim/Data/Tests')
-rw-r--r-- | OpenSim/Data/Tests/BasicAssetTest.cs | 35 | ||||
-rw-r--r-- | OpenSim/Data/Tests/BasicInventoryTest.cs | 56 | ||||
-rw-r--r-- | OpenSim/Data/Tests/PropertyCompareConstraint.cs | 28 |
3 files changed, 92 insertions, 27 deletions
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs index eddb999..91b613a 100644 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ b/OpenSim/Data/Tests/BasicAssetTest.cs | |||
@@ -84,7 +84,7 @@ namespace OpenSim.Data.Tests | |||
84 | a1.Data = asset1; | 84 | a1.Data = asset1; |
85 | a2.Data = asset1; | 85 | a2.Data = asset1; |
86 | a3.Data = asset1; | 86 | a3.Data = asset1; |
87 | 87 | ||
88 | a1.FullID = uuid1; | 88 | a1.FullID = uuid1; |
89 | a2.FullID = uuid2; | 89 | a2.FullID = uuid2; |
90 | a3.FullID = uuid3; | 90 | a3.FullID = uuid3; |
@@ -92,15 +92,40 @@ namespace OpenSim.Data.Tests | |||
92 | db.CreateAsset(a1); | 92 | db.CreateAsset(a1); |
93 | db.CreateAsset(a2); | 93 | db.CreateAsset(a2); |
94 | db.CreateAsset(a3); | 94 | db.CreateAsset(a3); |
95 | 95 | ||
96 | AssetBase a1a = db.FetchAsset(uuid1); | 96 | AssetBase a1a = db.FetchAsset(uuid1); |
97 | Assert.That(a1, Constraints.PropertyCompareConstraint(a1a)); | 97 | Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); |
98 | 98 | ||
99 | AssetBase a2a = db.FetchAsset(uuid2); | 99 | AssetBase a2a = db.FetchAsset(uuid2); |
100 | Assert.That(a2, Constraints.PropertyCompareConstraint(a2a)); | 100 | Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); |
101 | 101 | ||
102 | AssetBase a3a = db.FetchAsset(uuid3); | 102 | AssetBase a3a = db.FetchAsset(uuid3); |
103 | Assert.That(a3, Constraints.PropertyCompareConstraint(a3a)); | 103 | Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); |
104 | |||
105 | ScrambleForTesting.Scramble(a1a); | ||
106 | ScrambleForTesting.Scramble(a2a); | ||
107 | ScrambleForTesting.Scramble(a3a); | ||
108 | |||
109 | a1a.Data = asset1; | ||
110 | a2a.Data = asset1; | ||
111 | a3a.Data = asset1; | ||
112 | |||
113 | a1a.FullID = uuid1; | ||
114 | a2a.FullID = uuid2; | ||
115 | a3a.FullID = uuid3; | ||
116 | |||
117 | db.UpdateAsset(a1a); | ||
118 | db.UpdateAsset(a2a); | ||
119 | db.UpdateAsset(a3a); | ||
120 | |||
121 | AssetBase a1b = db.FetchAsset(uuid1); | ||
122 | Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a)); | ||
123 | |||
124 | AssetBase a2b = db.FetchAsset(uuid2); | ||
125 | Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a)); | ||
126 | |||
127 | AssetBase a3b = db.FetchAsset(uuid3); | ||
128 | Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a)); | ||
104 | } | 129 | } |
105 | 130 | ||
106 | [Test] | 131 | [Test] |
diff --git a/OpenSim/Data/Tests/BasicInventoryTest.cs b/OpenSim/Data/Tests/BasicInventoryTest.cs index 967c6e7..21552c8 100644 --- a/OpenSim/Data/Tests/BasicInventoryTest.cs +++ b/OpenSim/Data/Tests/BasicInventoryTest.cs | |||
@@ -258,17 +258,59 @@ namespace OpenSim.Data.Tests | |||
258 | [Test] | 258 | [Test] |
259 | public void T104_RandomUpdateItem() | 259 | public void T104_RandomUpdateItem() |
260 | { | 260 | { |
261 | InventoryItemBase expected = db.getInventoryItem(item1); | 261 | UUID owner = UUID.Random(); |
262 | UUID folder = UUID.Random(); | ||
263 | UUID rootId = UUID.Random(); | ||
264 | UUID rootAsset = UUID.Random(); | ||
265 | InventoryFolderBase f1 = NewFolder(folder, zero, owner, name1); | ||
266 | ScrambleForTesting.Scramble(f1); | ||
267 | f1.Owner = owner; | ||
268 | f1.ParentID = zero; | ||
269 | f1.ID = folder; | ||
270 | |||
271 | // succeed with true | ||
272 | db.addInventoryFolder(f1); | ||
273 | InventoryFolderBase f1a = db.getUserRootFolder(owner); | ||
274 | Assert.That(f1a, Constraints.PropertyCompareConstraint(f1)); | ||
275 | |||
276 | ScrambleForTesting.Scramble(f1a); | ||
277 | f1a.Owner = owner; | ||
278 | f1a.ParentID = zero; | ||
279 | f1a.ID = folder; | ||
280 | db.updateInventoryFolder(f1a); | ||
281 | |||
282 | InventoryFolderBase f1b = db.getUserRootFolder(owner); | ||
283 | Assert.That(f1b, Constraints.PropertyCompareConstraint(f1a)); | ||
284 | |||
285 | //Now we have a valid folder to insert into, we can insert the item. | ||
286 | InventoryItemBase root = NewItem(rootId, folder, owner, iname1, rootAsset); | ||
287 | ScrambleForTesting.Scramble(root); | ||
288 | root.ID = rootId; | ||
289 | root.AssetID = rootAsset; | ||
290 | root.Owner = owner; | ||
291 | root.Folder = folder; | ||
292 | db.addInventoryItem(root); | ||
293 | |||
294 | InventoryItemBase expected = db.getInventoryItem(rootId); | ||
295 | Assert.That(expected, Constraints.PropertyCompareConstraint(root) | ||
296 | .IgnoreProperty(x => x.InvType) | ||
297 | .IgnoreProperty(x => x.CreatorIdAsUuid) | ||
298 | .IgnoreProperty(x => x.Description) | ||
299 | .IgnoreProperty(x => x.CreatorId)); | ||
300 | |||
262 | ScrambleForTesting.Scramble(expected); | 301 | ScrambleForTesting.Scramble(expected); |
263 | expected.ID = item1; | 302 | expected.ID = rootId; |
303 | expected.AssetID = rootAsset; | ||
304 | expected.Owner = owner; | ||
305 | expected.Folder = folder; | ||
264 | db.updateInventoryItem(expected); | 306 | db.updateInventoryItem(expected); |
265 | 307 | ||
266 | InventoryItemBase actual = db.getInventoryItem(item1); | 308 | InventoryItemBase actual = db.getInventoryItem(rootId); |
267 | Assert.That(actual, Constraints.PropertyCompareConstraint(expected) | 309 | Assert.That(actual, Constraints.PropertyCompareConstraint(expected) |
268 | .IgnoreProperty(x=>x.InvType) | 310 | .IgnoreProperty(x => x.InvType) |
269 | .IgnoreProperty(x=>x.CreatorIdAsUuid) | 311 | .IgnoreProperty(x => x.CreatorIdAsUuid) |
270 | .IgnoreProperty(x=>x.Description) | 312 | .IgnoreProperty(x => x.Description) |
271 | .IgnoreProperty(x=>x.CreatorId)); | 313 | .IgnoreProperty(x => x.CreatorId)); |
272 | } | 314 | } |
273 | 315 | ||
274 | [Test] | 316 | [Test] |
diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs index 5f53725..d64a51e 100644 --- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs +++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs | |||
@@ -69,6 +69,19 @@ namespace OpenSim.Data.Tests | |||
69 | 69 | ||
70 | private bool ObjectCompare(object expected, object actual, Stack<string> propertyNames) | 70 | private bool ObjectCompare(object expected, object actual, Stack<string> propertyNames) |
71 | { | 71 | { |
72 | //If they are both null, they are equal | ||
73 | if (actual == null && expected == null) | ||
74 | return true; | ||
75 | |||
76 | //If only one is null, then they aren't | ||
77 | if (actual == null || expected == null) | ||
78 | { | ||
79 | failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray()); | ||
80 | failingActual = actual; | ||
81 | failingExpected = expected; | ||
82 | return false; | ||
83 | } | ||
84 | |||
72 | //prevent loops... | 85 | //prevent loops... |
73 | if(propertyNames.Count > 50) | 86 | if(propertyNames.Count > 50) |
74 | { | 87 | { |
@@ -195,21 +208,6 @@ namespace OpenSim.Data.Tests | |||
195 | object actualValue = property.GetValue(actual, null); | 208 | object actualValue = property.GetValue(actual, null); |
196 | object expectedValue = property.GetValue(expected, null); | 209 | object expectedValue = property.GetValue(expected, null); |
197 | 210 | ||
198 | //If they are both null, they are equal | ||
199 | if (actualValue == null && expectedValue == null) | ||
200 | continue; | ||
201 | |||
202 | //If only one is null, then they aren't | ||
203 | if (actualValue == null || expectedValue == null) | ||
204 | { | ||
205 | propertyNames.Push(property.Name); | ||
206 | failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray()); | ||
207 | propertyNames.Pop(); | ||
208 | failingActual = actualValue; | ||
209 | failingExpected = expectedValue; | ||
210 | return false; | ||
211 | } | ||
212 | |||
213 | propertyNames.Push(property.Name); | 211 | propertyNames.Push(property.Name); |
214 | if (!ObjectCompare(expectedValue, actualValue, propertyNames)) | 212 | if (!ObjectCompare(expectedValue, actualValue, propertyNames)) |
215 | return false; | 213 | return false; |