aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs10
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs13
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs17
-rw-r--r--OpenSim/Data/MySQL/Tests/MySQLGridTest.cs8
-rw-r--r--OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs12
-rw-r--r--OpenSim/Data/SQLite/SQLiteAssetData.cs2
-rw-r--r--OpenSim/Data/SQLite/SQLiteInventoryStore.cs3
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs29
-rw-r--r--OpenSim/Data/Tests/BasicAssetTest.cs78
-rw-r--r--OpenSim/Data/Tests/BasicEstateTest.cs28
-rw-r--r--OpenSim/Data/Tests/BasicGridTest.cs97
-rw-r--r--OpenSim/Data/Tests/BasicInventoryTest.cs86
-rw-r--r--OpenSim/Data/Tests/BasicRegionTest.cs65
-rw-r--r--OpenSim/Data/Tests/BasicUserTest.cs39
-rw-r--r--OpenSim/Data/Tests/PropertyCompareConstraint.cs200
-rw-r--r--OpenSim/Data/Tests/PropertyScrambler.cs (renamed from OpenSim/Data/Tests/ScrambleForTesting.cs)101
16 files changed, 502 insertions, 286 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 26cdd06..0865083 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -168,6 +168,7 @@ namespace OpenSim.Data.MySQL
168 } 168 }
169 asset.Name = (string) dbReader["name"]; 169 asset.Name = (string) dbReader["name"];
170 asset.Type = (sbyte) dbReader["assetType"]; 170 asset.Type = (sbyte) dbReader["assetType"];
171 asset.Temporary = (bool)dbReader["temporary"];
171 } 172 }
172 dbReader.Close(); 173 dbReader.Close();
173 cmd.Dispose(); 174 cmd.Dispose();
@@ -195,18 +196,11 @@ namespace OpenSim.Data.MySQL
195 { 196 {
196 lock (_dbConnection) 197 lock (_dbConnection)
197 { 198 {
198 //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID);
199 if (ExistsAsset(asset.FullID))
200 {
201 //m_log.Info("[ASSET DB]: Asset exists already, ignoring.");
202 return;
203 }
204
205 _dbConnection.CheckConnection(); 199 _dbConnection.CheckConnection();
206 200
207 MySqlCommand cmd = 201 MySqlCommand cmd =
208 new MySqlCommand( 202 new MySqlCommand(
209 "insert INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + 203 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" +
210 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", 204 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)",
211 _dbConnection.Connection); 205 _dbConnection.Connection);
212 206
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index a4b8663..4521a0f 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -342,7 +342,7 @@ namespace OpenSim.Data.MySQL
342 item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; 342 item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
343 item.GroupPermissions = (uint) reader["inventoryGroupPermissions"]; 343 item.GroupPermissions = (uint) reader["inventoryGroupPermissions"];
344 item.SalePrice = (int) reader["salePrice"]; 344 item.SalePrice = (int) reader["salePrice"];
345 item.SaleType = Convert.ToByte(reader["saleType"]); 345 item.SaleType = unchecked((byte)(Convert.ToSByte(reader["saleType"])));
346 item.CreationDate = (int) reader["creationDate"]; 346 item.CreationDate = (int) reader["creationDate"];
347 item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); 347 item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
348 item.Flags = (uint) reader["flags"]; 348 item.Flags = (uint) reader["flags"];
@@ -423,7 +423,7 @@ namespace OpenSim.Data.MySQL
423 /// <summary> 423 /// <summary>
424 /// Returns a specified inventory folder 424 /// Returns a specified inventory folder
425 /// </summary> 425 /// </summary>
426 /// <param name="folder">The folder to return</param> 426 /// <param name="folderID">The folder to return</param>
427 /// <returns>A folder class</returns> 427 /// <returns>A folder class</returns>
428 public InventoryFolderBase getInventoryFolder(UUID folderID) 428 public InventoryFolderBase getInventoryFolder(UUID folderID)
429 { 429 {
@@ -438,8 +438,9 @@ namespace OpenSim.Data.MySQL
438 result.Parameters.AddWithValue("?uuid", folderID.ToString()); 438 result.Parameters.AddWithValue("?uuid", folderID.ToString());
439 MySqlDataReader reader = result.ExecuteReader(); 439 MySqlDataReader reader = result.ExecuteReader();
440 440
441 reader.Read(); 441 InventoryFolderBase folder = null;
442 InventoryFolderBase folder = readInventoryFolder(reader); 442 if (reader.Read())
443 folder = readInventoryFolder(reader);
443 reader.Close(); 444 reader.Close();
444 result.Dispose(); 445 result.Dispose();
445 446
@@ -506,7 +507,7 @@ namespace OpenSim.Data.MySQL
506 result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); 507 result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
507 result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); 508 result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
508 result.Parameters.AddWithValue("?salePrice", item.SalePrice); 509 result.Parameters.AddWithValue("?salePrice", item.SalePrice);
509 result.Parameters.AddWithValue("?saleType", item.SaleType); 510 result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType));
510 result.Parameters.AddWithValue("?creationDate", item.CreationDate); 511 result.Parameters.AddWithValue("?creationDate", item.CreationDate);
511 result.Parameters.AddWithValue("?groupID", item.GroupID); 512 result.Parameters.AddWithValue("?groupID", item.GroupID);
512 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); 513 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
@@ -603,7 +604,7 @@ namespace OpenSim.Data.MySQL
603 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); 604 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString());
604 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); 605 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
605 cmd.Parameters.AddWithValue("?folderName", folderName); 606 cmd.Parameters.AddWithValue("?folderName", folderName);
606 cmd.Parameters.AddWithValue("?type", (short) folder.Type); 607 cmd.Parameters.AddWithValue("?type", folder.Type);
607 cmd.Parameters.AddWithValue("?version", folder.Version); 608 cmd.Parameters.AddWithValue("?version", folder.Version);
608 609
609 try 610 try
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 2166845..9c2ee4a 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -834,7 +834,10 @@ namespace OpenSim.Data.MySQL
834 // explicit conversion of integers is required, which sort 834 // explicit conversion of integers is required, which sort
835 // of sucks. No idea if there is a shortcut here or not. 835 // of sucks. No idea if there is a shortcut here or not.
836 prim.CreationDate = Convert.ToInt32(row["CreationDate"]); 836 prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
837 prim.Name = (String) row["Name"]; 837 if (row["Name"] != DBNull.Value)
838 prim.Name = (String)row["Name"];
839 else
840 prim.Name = string.Empty;
838 // various text fields 841 // various text fields
839 prim.Text = (String) row["Text"]; 842 prim.Text = (String) row["Text"];
840 prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), 843 prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
@@ -945,12 +948,12 @@ namespace OpenSim.Data.MySQL
945 prim.DIE_AT_EDGE = true; 948 prim.DIE_AT_EDGE = true;
946 949
947 prim.SalePrice = Convert.ToInt32(row["SalePrice"]); 950 prim.SalePrice = Convert.ToInt32(row["SalePrice"]);
948 prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); 951 prim.ObjectSaleType = unchecked((byte)Convert.ToSByte(row["SaleType"]));
949 952
950 prim.Material = Convert.ToByte(row["Material"]); 953 prim.Material = unchecked((byte)Convert.ToSByte(row["Material"]));
951 954
952 if (!(row["ClickAction"] is DBNull)) 955 if (!(row["ClickAction"] is DBNull))
953 prim.ClickAction = (byte)Convert.ToByte(row["ClickAction"]); 956 prim.ClickAction = unchecked((byte)Convert.ToSByte(row["ClickAction"]));
954 957
955 prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); 958 prim.CollisionSound = new UUID(row["CollisionSound"].ToString());
956 prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); 959 prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]);
@@ -1277,12 +1280,12 @@ namespace OpenSim.Data.MySQL
1277 cmd.Parameters.AddWithValue("DieAtEdge", 0); 1280 cmd.Parameters.AddWithValue("DieAtEdge", 0);
1278 1281
1279 cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice); 1282 cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice);
1280 cmd.Parameters.AddWithValue("SaleType", Convert.ToInt16(prim.ObjectSaleType)); 1283 cmd.Parameters.AddWithValue("SaleType", unchecked((sbyte)(prim.ObjectSaleType)));
1281 1284
1282 byte clickAction = prim.ClickAction; 1285 byte clickAction = prim.ClickAction;
1283 cmd.Parameters.AddWithValue("ClickAction", clickAction); 1286 cmd.Parameters.AddWithValue("ClickAction", unchecked((sbyte)(clickAction)));
1284 1287
1285 cmd.Parameters.AddWithValue("Material", prim.Material); 1288 cmd.Parameters.AddWithValue("Material", unchecked((sbyte)(prim.Material)));
1286 1289
1287 cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); 1290 cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString());
1288 cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); 1291 cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume);
diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
index 7c36375..d1d5c2a 100644
--- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
+++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
@@ -62,11 +62,18 @@ namespace OpenSim.Data.MySQL.Tests
62 m_log.Error("Exception {0}", e); 62 m_log.Error("Exception {0}", e);
63 Assert.Ignore(); 63 Assert.Ignore();
64 } 64 }
65
66 // This actually does the roll forward assembly stuff
67 Assembly assem = GetType().Assembly;
68 Migration m = new Migration(database.Connection, assem, "GridStore");
69
70 m.Update();
65 } 71 }
66 72
67 [TestFixtureTearDown] 73 [TestFixtureTearDown]
68 public void Cleanup() 74 public void Cleanup()
69 { 75 {
76 m_log.Warn("Cleaning up.");
70 if (db != null) 77 if (db != null)
71 { 78 {
72 db.Dispose(); 79 db.Dispose();
@@ -74,6 +81,7 @@ namespace OpenSim.Data.MySQL.Tests
74 // if a new table is added, it has to be dropped here 81 // if a new table is added, it has to be dropped here
75 if (database != null) 82 if (database != null)
76 { 83 {
84 database.ExecuteSql("drop table migrations");
77 database.ExecuteSql("drop table regions"); 85 database.ExecuteSql("drop table regions");
78 } 86 }
79 } 87 }
diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
index 23c1ec5..a3a32dc 100644
--- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
+++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
@@ -53,6 +53,7 @@ namespace OpenSim.Data.MySQL.Tests
53 try 53 try
54 { 54 {
55 database = new MySQLManager(connect); 55 database = new MySQLManager(connect);
56 DropTables();
56 db = new MySQLInventoryData(); 57 db = new MySQLInventoryData();
57 db.Initialise(connect); 58 db.Initialise(connect);
58 } 59 }
@@ -72,10 +73,15 @@ namespace OpenSim.Data.MySQL.Tests
72 } 73 }
73 if (database != null) 74 if (database != null)
74 { 75 {
75 database.ExecuteSql("drop table inventoryitems"); 76 DropTables();
76 database.ExecuteSql("drop table inventoryfolders");
77 database.ExecuteSql("drop table migrations");
78 } 77 }
79 } 78 }
79
80 private void DropTables()
81 {
82 database.ExecuteSql("drop table IF EXISTS inventoryitems");
83 database.ExecuteSql("drop table IF EXISTS inventoryfolders");
84 database.ExecuteSql("drop table IF EXISTS migrations");
85 }
80 } 86 }
81} 87}
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index b09c1c9..72af7a0 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -183,7 +183,7 @@ namespace OpenSim.Data.SQLite
183 int assetLength = (asset.Data != null) ? asset.Data.Length : 0; 183 int assetLength = (asset.Data != null) ? asset.Data.Length : 0;
184 184
185 m_log.Info("[ASSET DB]: " + 185 m_log.Info("[ASSET DB]: " +
186 string.Format("Loaded {6} {5} Asset: [{0}][{3}] \"{1}\":{2} ({7} bytes)", 186 string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)",
187 asset.FullID, asset.Name, asset.Description, asset.Type, 187 asset.FullID, asset.Name, asset.Description, asset.Type,
188 temporary, local, assetLength)); 188 temporary, local, assetLength));
189 } 189 }
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
index 97c40ba..e5f7a50 100644
--- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
+++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
@@ -301,7 +301,8 @@ namespace OpenSim.Data.SQLite
301 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; 301 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
302 302
303 inventoryRow = inventoryFolderTable.Rows.Find(item.Folder.ToString()); 303 inventoryRow = inventoryFolderTable.Rows.Find(item.Folder.ToString());
304 inventoryRow["version"] = (int)inventoryRow["version"] + 1; 304 if (inventoryRow != null) //MySQL doesn't throw an exception here, so sqlite shouldn't either.
305 inventoryRow["version"] = (int)inventoryRow["version"] + 1;
305 306
306 invFoldersDa.Update(ds, "inventoryfolders"); 307 invFoldersDa.Update(ds, "inventoryfolders");
307 } 308 }
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index d2548c2..0259ac5 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -307,26 +307,21 @@ namespace OpenSim.Data.SQLite
307 /// <param name="regionUUID">the region UUID</param> 307 /// <param name="regionUUID">the region UUID</param>
308 public void StoreObject(SceneObjectGroup obj, UUID regionUUID) 308 public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
309 { 309 {
310 uint flags = obj.RootPart.GetEffectiveObjectFlags();
311
312 // Eligibility check
313 //
314 if ((flags & (uint)PrimFlags.Temporary) != 0)
315 return;
316 if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0)
317 return;
318
310 lock (ds) 319 lock (ds)
311 { 320 {
312 foreach (SceneObjectPart prim in obj.Children.Values) 321 foreach (SceneObjectPart prim in obj.Children.Values)
313 { 322 {
314 if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 323 m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
315 && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) 324 addPrim(prim, obj.UUID, regionUUID);
316 {
317 m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
318 addPrim(prim, obj.UUID, regionUUID);
319 }
320 else if (prim.Stopped)
321 {
322 //m_log.Info("[DATASTORE]: " +
323 //"Adding stopped obj: " + obj.UUID + " to region: " + regionUUID);
324 //addPrim(prim, obj.UUID.ToString(), regionUUID.ToString());
325 }
326 else
327 {
328 // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID);
329 }
330 } 325 }
331 } 326 }
332 327
@@ -1130,7 +1125,7 @@ namespace OpenSim.Data.SQLite
1130 // explicit conversion of integers is required, which sort 1125 // explicit conversion of integers is required, which sort
1131 // of sucks. No idea if there is a shortcut here or not. 1126 // of sucks. No idea if there is a shortcut here or not.
1132 prim.CreationDate = Convert.ToInt32(row["CreationDate"]); 1127 prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
1133 prim.Name = (String) row["Name"]; 1128 prim.Name = row["Name"] == DBNull.Value ? string.Empty : (string)row["Name"];
1134 // various text fields 1129 // various text fields
1135 prim.Text = (String) row["Text"]; 1130 prim.Text = (String) row["Text"];
1136 prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), 1131 prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs
index e85a6a7..09131c1 100644
--- a/OpenSim/Data/Tests/BasicAssetTest.cs
+++ b/OpenSim/Data/Tests/BasicAssetTest.cs
@@ -26,20 +26,19 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using log4net.Config; 30using log4net.Config;
30using NUnit.Framework; 31using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers; 32using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 33using OpenMetaverse;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using log4net; 35using log4net;
35using System.Reflection;
36 36
37namespace OpenSim.Data.Tests 37namespace OpenSim.Data.Tests
38{ 38{
39 public class BasicAssetTest 39 public class BasicAssetTest
40 { 40 {
41 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 public IAssetDataPlugin db;
42 public AssetDataBase db;
43 public UUID uuid1; 42 public UUID uuid1;
44 public UUID uuid2; 43 public UUID uuid2;
45 public UUID uuid3; 44 public UUID uuid3;
@@ -47,14 +46,7 @@ namespace OpenSim.Data.Tests
47 46
48 public void SuperInit() 47 public void SuperInit()
49 { 48 {
50 try 49 OpenSim.Tests.Common.TestLogging.LogToConsole();
51 {
52 XmlConfigurator.Configure();
53 }
54 catch (Exception)
55 {
56 // I don't care, just leave log4net off
57 }
58 50
59 uuid1 = UUID.Random(); 51 uuid1 = UUID.Random();
60 uuid2 = UUID.Random(); 52 uuid2 = UUID.Random();
@@ -81,41 +73,59 @@ namespace OpenSim.Data.Tests
81 a2.Data = asset1; 73 a2.Data = asset1;
82 a3.Data = asset1; 74 a3.Data = asset1;
83 75
76 PropertyScrambler<AssetBase> scrambler = new PropertyScrambler<AssetBase>()
77 .DontScramble(x => x.Data)
78 .DontScramble(x => x.ID)
79 .DontScramble(x => x.FullID)
80 .DontScramble(x => x.Metadata.ID)
81 .DontScramble(x => x.Metadata.FullID);
82
83 scrambler.Scramble(a1);
84 scrambler.Scramble(a2);
85 scrambler.Scramble(a3);
86
84 db.CreateAsset(a1); 87 db.CreateAsset(a1);
85 db.CreateAsset(a2); 88 db.CreateAsset(a2);
86 db.CreateAsset(a3); 89 db.CreateAsset(a3);
87 90
88 AssetBase a1a = db.FetchAsset(uuid1); 91 AssetBase a1a = db.FetchAsset(uuid1);
89 Assert.That(a1.ID, Is.EqualTo(a1a.ID), "Assert.That(a1.ID, Is.EqualTo(a1a.ID))"); 92 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
90 Assert.That(a1.Name, Is.EqualTo(a1a.Name), "Assert.That(a1.Name, Is.EqualTo(a1a.Name))");
91 93
92 AssetBase a2a = db.FetchAsset(uuid2); 94 AssetBase a2a = db.FetchAsset(uuid2);
93 Assert.That(a2.ID, Is.EqualTo(a2a.ID), "Assert.That(a2.ID, Is.EqualTo(a2a.ID))"); 95 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
94 Assert.That(a2.Name, Is.EqualTo(a2a.Name), "Assert.That(a2.Name, Is.EqualTo(a2a.Name))");
95 96
96 AssetBase a3a = db.FetchAsset(uuid3); 97 AssetBase a3a = db.FetchAsset(uuid3);
97 Assert.That(a3.ID, Is.EqualTo(a3a.ID), "Assert.That(a3.ID, Is.EqualTo(a3a.ID))"); 98 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
98 Assert.That(a3.Name, Is.EqualTo(a3a.Name), "Assert.That(a3.Name, Is.EqualTo(a3a.Name))"); 99
99 } 100 scrambler.Scramble(a1a);
101 scrambler.Scramble(a2a);
102 scrambler.Scramble(a3a);
103
104 db.UpdateAsset(a1a);
105 db.UpdateAsset(a2a);
106 db.UpdateAsset(a3a);
107
108 AssetBase a1b = db.FetchAsset(uuid1);
109 Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));
110
111 AssetBase a2b = db.FetchAsset(uuid2);
112 Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));
113
114 AssetBase a3b = db.FetchAsset(uuid3);
115 Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));
100 116
101 [Test]
102 public void T011_ExistsSimpleAsset()
103 {
104 Assert.That(db.ExistsAsset(uuid1), Is.True); 117 Assert.That(db.ExistsAsset(uuid1), Is.True);
105 Assert.That(db.ExistsAsset(uuid2), Is.True); 118 Assert.That(db.ExistsAsset(uuid2), Is.True);
106 Assert.That(db.ExistsAsset(uuid3), Is.True); 119 Assert.That(db.ExistsAsset(uuid3), Is.True);
107 }
108 120
109 // this has questionable use, but it is in the interface at the moment. 121 List<AssetMetadata> metadatas = db.FetchAssetMetadataSet(0, 1000);
110 // [Test] 122
111 // public void T012_DeleteAsset() 123 AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1);
112 // { 124 Assert.That(metadata.Name, Is.EqualTo(a1b.Name));
113 // db.DeleteAsset(uuid1); 125 Assert.That(metadata.Description, Is.EqualTo(a1b.Description));
114 // db.DeleteAsset(uuid2); 126 Assert.That(metadata.Type, Is.EqualTo(a1b.Type));
115 // db.DeleteAsset(uuid3); 127 Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary));
116 // Assert.That(db.ExistsAsset(uuid1), Is.False); 128 Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID));
117 // Assert.That(db.ExistsAsset(uuid2), Is.False); 129 }
118 // Assert.That(db.ExistsAsset(uuid3), Is.False);
119 // }
120 } 130 }
121} 131}
diff --git a/OpenSim/Data/Tests/BasicEstateTest.cs b/OpenSim/Data/Tests/BasicEstateTest.cs
index a0266b3..284d066 100644
--- a/OpenSim/Data/Tests/BasicEstateTest.cs
+++ b/OpenSim/Data/Tests/BasicEstateTest.cs
@@ -40,7 +40,6 @@ namespace OpenSim.Data.Tests
40{ 40{
41 public class BasicEstateTest 41 public class BasicEstateTest
42 { 42 {
43 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 public IEstateDataStore db; 43 public IEstateDataStore db;
45 public IRegionDataStore regionDb; 44 public IRegionDataStore regionDb;
46 45
@@ -57,14 +56,7 @@ namespace OpenSim.Data.Tests
57 56
58 public void SuperInit() 57 public void SuperInit()
59 { 58 {
60 try 59 OpenSim.Tests.Common.TestLogging.LogToConsole();
61 {
62 XmlConfigurator.Configure();
63 }
64 catch (Exception)
65 {
66 // I don't care, just leave log4net off
67 }
68 } 60 }
69 61
70 #region 0Tests 62 #region 0Tests
@@ -163,6 +155,24 @@ namespace OpenSim.Data.Tests
163 } 155 }
164 156
165 [Test] 157 [Test]
158 private void T012_EstateSettingsRandomStorage()
159 {
160
161 // Letting estate store generate rows to database for us
162 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
163 new PropertyScrambler<EstateSettings>().Scramble(originalSettings);
164
165 // Saving settings.
166 db.StoreEstateSettings(originalSettings);
167
168 // Loading settings to another instance variable.
169 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
170
171 // Checking that loaded values are correct.
172 Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
173 }
174
175 [Test]
166 public void T020_EstateSettingsManagerList() 176 public void T020_EstateSettingsManagerList()
167 { 177 {
168 // Letting estate store generate rows to database for us 178 // Letting estate store generate rows to database for us
diff --git a/OpenSim/Data/Tests/BasicGridTest.cs b/OpenSim/Data/Tests/BasicGridTest.cs
index 85273c5..de8fb48 100644
--- a/OpenSim/Data/Tests/BasicGridTest.cs
+++ b/OpenSim/Data/Tests/BasicGridTest.cs
@@ -28,81 +28,47 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using log4net.Config;
32using NUnit.Framework; 31using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers; 32using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using log4net;
36using System.Reflection;
37 34
38namespace OpenSim.Data.Tests 35namespace OpenSim.Data.Tests
39{ 36{
40 public class BasicGridTest 37 public class BasicGridTest
41 { 38 {
42 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 39 public IGridDataPlugin db;
43 public GridDataBase db;
44 public UUID region1, region2, region3; 40 public UUID region1, region2, region3;
45 public UUID zero = UUID.Zero; 41 public UUID zero = UUID.Zero;
46 public static Random random; 42 public static Random random = new Random();
47 43
48 [TearDown] 44 [TearDown]
49 public void removeAllRegions() 45 public void removeAllRegions()
50 { 46 {
51 // Clean up all the regions. 47 // Clean up all the regions.
52 foreach (RegionProfileData region in db.GetRegionsByName("", 100)) 48 List<RegionProfileData> regions = db.GetRegionsByName("", 100);
49 if (regions != null)
53 { 50 {
54 db.DeleteProfile(region.Uuid.ToString()); 51 foreach (RegionProfileData region in regions)
52 {
53 db.DeleteProfile(region.Uuid.ToString());
54 }
55 } 55 }
56 } 56 }
57 57
58 public void SuperInit() 58 public void SuperInit()
59 { 59 {
60 try 60 OpenSim.Tests.Common.TestLogging.LogToConsole();
61 {
62 XmlConfigurator.Configure();
63 }
64 catch (Exception)
65 {
66 // I don't care, just leave log4net off
67 }
68 region1 = UUID.Random(); 61 region1 = UUID.Random();
69 region2 = UUID.Random(); 62 region2 = UUID.Random();
70 region3 = UUID.Random(); 63 region3 = UUID.Random();
71 random = new Random();
72 } 64 }
73 65
74 protected RegionProfileData createRegion(UUID regionUUID, string regionName) 66 protected RegionProfileData createRegion(UUID regionUUID, string regionName)
75 { 67 {
76 RegionProfileData reg = new RegionProfileData(); 68 RegionProfileData reg = new RegionProfileData();
69 new PropertyScrambler<RegionProfileData>().Scramble(reg);
77 reg.Uuid = regionUUID; 70 reg.Uuid = regionUUID;
78 reg.RegionName = regionName; 71 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 72
107 db.AddProfile(reg); 73 db.AddProfile(reg);
108 74
@@ -119,47 +85,12 @@ namespace OpenSim.Data.Tests
119 } 85 }
120 86
121 [Test] 87 [Test]
122 public void T999_StillNull()
123 {
124 Assert.That(db.GetProfileByUUID(zero),Is.Null);
125 }
126
127 [Test]
128 public void T011_AddRetrieveCompleteTest() 88 public void T011_AddRetrieveCompleteTest()
129 { 89 {
130 RegionProfileData newreg = createRegion(region2, "|<Goth@m Ci1y>|"); 90 RegionProfileData newreg = createRegion(region2, "|<Goth@m Ci1y>|");
131 RegionProfileData retreg = db.GetProfileByUUID(region2); 91 RegionProfileData retreg = db.GetProfileByUUID(region2);
132 92
133 Assert.That(retreg.RegionName, Is.EqualTo(newreg.RegionName), "Assert.That(retreg.RegionName, Is.EqualTo(newreg.RegionName))"); 93 Assert.That(retreg, Constraints.PropertyCompareConstraint(newreg).IgnoreProperty(x => x.RegionOnline));
134 Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))");
135 Assert.That(retreg.RegionHandle, Is.EqualTo(newreg.RegionHandle), "Assert.That(retreg.RegionHandle, Is.EqualTo(newreg.RegionHandle))");
136 Assert.That(retreg.RegionLocX, Is.EqualTo(newreg.RegionLocX), "Assert.That(retreg.RegionLocX, Is.EqualTo(newreg.RegionLocX))");
137 Assert.That(retreg.RegionLocY, Is.EqualTo(newreg.RegionLocY), "Assert.That(retreg.RegionLocY, Is.EqualTo(newreg.RegionLocY))");
138 Assert.That(retreg.RegionLocZ, Is.EqualTo(newreg.RegionLocZ), "Assert.That(retreg.RegionLocZ, Is.EqualTo(newreg.RegionLocZ))");
139 Assert.That(retreg.RegionSendKey, Is.EqualTo(newreg.RegionSendKey), "Assert.That(retreg.RegionSendKey, Is.EqualTo(newreg.RegionSendKey))");
140 Assert.That(retreg.RegionRecvKey, Is.EqualTo(newreg.RegionRecvKey), "Assert.That(retreg.RegionRecvKey, Is.EqualTo(newreg.RegionRecvKey))");
141 Assert.That(retreg.RegionSecret, Is.EqualTo(newreg.RegionSecret), "Assert.That(retreg.RegionSecret, Is.EqualTo(newreg.RegionSecret))");
142 Assert.That(retreg.RegionOnline, Is.EqualTo(newreg.RegionOnline), "Assert.That(retreg.RegionOnline, Is.EqualTo(newreg.RegionOnline))");
143 Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID), "Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID))");
144 Assert.That(retreg.ServerIP, Is.EqualTo(newreg.ServerIP), "Assert.That(retreg.ServerIP, Is.EqualTo(newreg.ServerIP))");
145 Assert.That(retreg.ServerPort, Is.EqualTo(newreg.ServerPort), "Assert.That(retreg.ServerPort, Is.EqualTo(newreg.ServerPort))");
146 Assert.That(retreg.ServerURI, Is.EqualTo(newreg.ServerURI), "Assert.That(retreg.ServerURI, Is.EqualTo(newreg.ServerURI))");
147 Assert.That(retreg.ServerHttpPort, Is.EqualTo(newreg.ServerHttpPort), "Assert.That(retreg.ServerHttpPort, Is.EqualTo(newreg.ServerHttpPort))");
148 Assert.That(retreg.ServerRemotingPort, Is.EqualTo(newreg.ServerRemotingPort), "Assert.That(retreg.ServerRemotingPort, Is.EqualTo(newreg.ServerRemotingPort))");
149 Assert.That(retreg.NorthOverrideHandle, Is.EqualTo(newreg.NorthOverrideHandle), "Assert.That(retreg.NorthOverrideHandle, Is.EqualTo(newreg.NorthOverrideHandle))");
150 Assert.That(retreg.SouthOverrideHandle, Is.EqualTo(newreg.SouthOverrideHandle), "Assert.That(retreg.SouthOverrideHandle, Is.EqualTo(newreg.SouthOverrideHandle))");
151 Assert.That(retreg.EastOverrideHandle, Is.EqualTo(newreg.EastOverrideHandle), "Assert.That(retreg.EastOverrideHandle, Is.EqualTo(newreg.EastOverrideHandle))");
152 Assert.That(retreg.WestOverrideHandle, Is.EqualTo(newreg.WestOverrideHandle), "Assert.That(retreg.WestOverrideHandle, Is.EqualTo(newreg.WestOverrideHandle))");
153 Assert.That(retreg.RegionDataURI, Is.EqualTo(newreg.RegionDataURI), "Assert.That(retreg.RegionDataURI, Is.EqualTo(newreg.RegionDataURI))");
154 Assert.That(retreg.RegionAssetURI, Is.EqualTo(newreg.RegionAssetURI), "Assert.That(retreg.RegionAssetURI, Is.EqualTo(newreg.RegionAssetURI))");
155 Assert.That(retreg.RegionAssetSendKey, Is.EqualTo(newreg.RegionAssetSendKey), "Assert.That(retreg.RegionAssetSendKey, Is.EqualTo(newreg.RegionAssetSendKey))");
156 Assert.That(retreg.RegionAssetRecvKey, Is.EqualTo(newreg.RegionAssetRecvKey), "Assert.That(retreg.RegionAssetRecvKey, Is.EqualTo(newreg.RegionAssetRecvKey))");
157 Assert.That(retreg.RegionUserURI, Is.EqualTo(newreg.RegionUserURI), "Assert.That(retreg.RegionUserURI, Is.EqualTo(newreg.RegionUserURI))");
158 Assert.That(retreg.RegionUserSendKey, Is.EqualTo(newreg.RegionUserSendKey), "Assert.That(retreg.RegionUserSendKey, Is.EqualTo(newreg.RegionUserSendKey))");
159 Assert.That(retreg.RegionUserRecvKey, Is.EqualTo(newreg.RegionUserRecvKey), "Assert.That(retreg.RegionUserRecvKey, Is.EqualTo(newreg.RegionUserRecvKey))");
160 Assert.That(retreg.RegionMapTextureID, Is.EqualTo(newreg.RegionMapTextureID), "Assert.That(retreg.RegionMapTextureID, Is.EqualTo(newreg.RegionMapTextureID))");
161 Assert.That(retreg.Owner_uuid, Is.EqualTo(newreg.Owner_uuid), "Assert.That(retreg.Owner_uuid, Is.EqualTo(newreg.Owner_uuid))");
162 Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID), "Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID))");
163 94
164 retreg = db.GetProfileByHandle(newreg.RegionHandle); 95 retreg = db.GetProfileByHandle(newreg.RegionHandle);
165 Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))"); 96 Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))");
@@ -220,6 +151,12 @@ namespace OpenSim.Data.Tests
220 Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))"); 151 Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))");
221 } 152 }
222 153
154 [Test]
155 public void T999_StillNull()
156 {
157 Assert.That(db.GetProfileByUUID(zero), Is.Null);
158 }
159
223 protected static string RandomName() 160 protected static string RandomName()
224 { 161 {
225 StringBuilder name = new StringBuilder(); 162 StringBuilder name = new StringBuilder();
diff --git a/OpenSim/Data/Tests/BasicInventoryTest.cs b/OpenSim/Data/Tests/BasicInventoryTest.cs
index e13ed89..900186b 100644
--- a/OpenSim/Data/Tests/BasicInventoryTest.cs
+++ b/OpenSim/Data/Tests/BasicInventoryTest.cs
@@ -66,14 +66,7 @@ namespace OpenSim.Data.Tests
66 66
67 public void SuperInit() 67 public void SuperInit()
68 { 68 {
69 try 69 OpenSim.Tests.Common.TestLogging.LogToConsole();
70 {
71 XmlConfigurator.Configure();
72 }
73 catch (Exception)
74 {
75 // I don't care, just leave log4net off
76 }
77 70
78 folder1 = UUID.Random(); 71 folder1 = UUID.Random();
79 folder2 = UUID.Random(); 72 folder2 = UUID.Random();
@@ -115,16 +108,6 @@ namespace OpenSim.Data.Tests
115 Assert.That(db.getUserRootFolder(owner1), Is.Null); 108 Assert.That(db.getUserRootFolder(owner1), Is.Null);
116 } 109 }
117 110
118 [Test]
119 public void T999_StillNull()
120 {
121 // After all tests are run, these should still return no results
122 Assert.That(db.getInventoryFolder(zero), Is.Null);
123 Assert.That(db.getInventoryItem(zero), Is.Null);
124 Assert.That(db.getUserRootFolder(zero), Is.Null);
125 Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
126 }
127
128 // 01x - folder tests 111 // 01x - folder tests
129 [Test] 112 [Test]
130 public void T010_FolderNonParent() 113 public void T010_FolderNonParent()
@@ -248,7 +231,7 @@ namespace OpenSim.Data.Tests
248 } 231 }
249 232
250 [Test] 233 [Test]
251 public void T103UpdateItem() 234 public void T103_UpdateItem()
252 { 235 {
253 // TODO: probably shouldn't have the ability to have an 236 // TODO: probably shouldn't have the ability to have an
254 // owner of an item in a folder not owned by the user 237 // owner of an item in a folder not owned by the user
@@ -265,6 +248,71 @@ namespace OpenSim.Data.Tests
265 Assert.That(i1.Owner, Is.EqualTo(owner2), "Assert.That(i1.Owner, Is.EqualTo(owner2))"); 248 Assert.That(i1.Owner, Is.EqualTo(owner2), "Assert.That(i1.Owner, Is.EqualTo(owner2))");
266 } 249 }
267 250
251 [Test]
252 public void T104_RandomUpdateItem()
253 {
254 PropertyScrambler<InventoryFolderBase> folderScrambler =
255 new PropertyScrambler<InventoryFolderBase>()
256 .DontScramble(x => x.Owner)
257 .DontScramble(x => x.ParentID)
258 .DontScramble(x => x.ID);
259 UUID owner = UUID.Random();
260 UUID folder = UUID.Random();
261 UUID rootId = UUID.Random();
262 UUID rootAsset = UUID.Random();
263 InventoryFolderBase f1 = NewFolder(folder, zero, owner, name1);
264 folderScrambler.Scramble(f1);
265
266 db.addInventoryFolder(f1);
267 InventoryFolderBase f1a = db.getUserRootFolder(owner);
268 Assert.That(f1a, Constraints.PropertyCompareConstraint(f1));
269
270 folderScrambler.Scramble(f1a);
271
272 db.updateInventoryFolder(f1a);
273
274 InventoryFolderBase f1b = db.getUserRootFolder(owner);
275 Assert.That(f1b, Constraints.PropertyCompareConstraint(f1a));
276
277 //Now we have a valid folder to insert into, we can insert the item.
278 PropertyScrambler<InventoryItemBase> inventoryScrambler =
279 new PropertyScrambler<InventoryItemBase>()
280 .DontScramble(x => x.ID)
281 .DontScramble(x => x.AssetID)
282 .DontScramble(x => x.Owner)
283 .DontScramble(x => x.Folder);
284 InventoryItemBase root = NewItem(rootId, folder, owner, iname1, rootAsset);
285 inventoryScrambler.Scramble(root);
286 db.addInventoryItem(root);
287
288 InventoryItemBase expected = db.getInventoryItem(rootId);
289 Assert.That(expected, Constraints.PropertyCompareConstraint(root)
290 .IgnoreProperty(x => x.InvType)
291 .IgnoreProperty(x => x.CreatorIdAsUuid)
292 .IgnoreProperty(x => x.Description)
293 .IgnoreProperty(x => x.CreatorId));
294
295 inventoryScrambler.Scramble(expected);
296 db.updateInventoryItem(expected);
297
298 InventoryItemBase actual = db.getInventoryItem(rootId);
299 Assert.That(actual, Constraints.PropertyCompareConstraint(expected)
300 .IgnoreProperty(x => x.InvType)
301 .IgnoreProperty(x => x.CreatorIdAsUuid)
302 .IgnoreProperty(x => x.Description)
303 .IgnoreProperty(x => x.CreatorId));
304 }
305
306 [Test]
307 public void T999_StillNull()
308 {
309 // After all tests are run, these should still return no results
310 Assert.That(db.getInventoryFolder(zero), Is.Null);
311 Assert.That(db.getInventoryItem(zero), Is.Null);
312 Assert.That(db.getUserRootFolder(zero), Is.Null);
313 Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
314 }
315
268 private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset) 316 private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset)
269 { 317 {
270 InventoryItemBase i = new InventoryItemBase(); 318 InventoryItemBase i = new InventoryItemBase();
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs
index 836da78..8474921 100644
--- a/OpenSim/Data/Tests/BasicRegionTest.cs
+++ b/OpenSim/Data/Tests/BasicRegionTest.cs
@@ -71,14 +71,7 @@ namespace OpenSim.Data.Tests
71 71
72 public void SuperInit() 72 public void SuperInit()
73 { 73 {
74 try 74 OpenSim.Tests.Common.TestLogging.LogToConsole();
75 {
76 XmlConfigurator.Configure();
77 }
78 catch (Exception)
79 {
80 // I don't care, just leave log4net off
81 }
82 75
83 region1 = UUID.Random(); 76 region1 = UUID.Random();
84 region3 = UUID.Random(); 77 region3 = UUID.Random();
@@ -532,6 +525,62 @@ namespace OpenSim.Data.Tests
532 Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration), "Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration))"); 525 Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration), "Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration))");
533 } 526 }
534 } 527 }
528
529 [Test]
530 public void T016_RandomSogWithSceneParts()
531 {
532 PropertyScrambler<SceneObjectPart> scrambler =
533 new PropertyScrambler<SceneObjectPart>()
534 .DontScramble(x => x.UUID);
535 UUID tmpSog = UUID.Random();
536 UUID tmp1 = UUID.Random();
537 UUID tmp2 = UUID.Random();
538 UUID tmp3 = UUID.Random();
539 UUID newregion = UUID.Random();
540 SceneObjectPart p1 = new SceneObjectPart();
541 SceneObjectPart p2 = new SceneObjectPart();
542 SceneObjectPart p3 = new SceneObjectPart();
543 p1.Shape = PrimitiveBaseShape.Default;
544 p2.Shape = PrimitiveBaseShape.Default;
545 p3.Shape = PrimitiveBaseShape.Default;
546 p1.UUID = tmp1;
547 p2.UUID = tmp2;
548 p3.UUID = tmp3;
549 scrambler.Scramble(p1);
550 scrambler.Scramble(p2);
551 scrambler.Scramble(p3);
552
553 SceneObjectGroup sog = NewSOG("Sop 0", tmpSog, newregion);
554 PropertyScrambler<SceneObjectGroup> sogScrambler =
555 new PropertyScrambler<SceneObjectGroup>()
556 .DontScramble(x => x.UUID);
557 sogScrambler.Scramble(sog);
558 sog.UUID = tmpSog;
559 sog.AddPart(p1);
560 sog.AddPart(p2);
561 sog.AddPart(p3);
562
563 SceneObjectPart[] parts = sog.GetParts();
564 Assert.That(parts.Length, Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))");
565
566 db.StoreObject(sog, newregion);
567 List<SceneObjectGroup> sogs = db.LoadObjects(newregion);
568 Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))");
569 SceneObjectGroup newsog = sogs[0];
570
571 SceneObjectPart[] newparts = newsog.GetParts();
572 Assert.That(newparts.Length, Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))");
573
574 Assert.That(newsog, Constraints.PropertyCompareConstraint(sog)
575 .IgnoreProperty(x=>x.LocalId)
576 .IgnoreProperty(x=>x.HasGroupChanged)
577 .IgnoreProperty(x=>x.IsSelected)
578 .IgnoreProperty(x=>x.RegionHandle)
579 .IgnoreProperty(x=>x.RegionUUID)
580 .IgnoreProperty(x=>x.Scene)
581 .IgnoreProperty(x=>x.Children)
582 .IgnoreProperty(x=>x.RootPart));
583 }
535 584
536 [Test] 585 [Test]
537 public void T020_PrimInventoryEmpty() 586 public void T020_PrimInventoryEmpty()
diff --git a/OpenSim/Data/Tests/BasicUserTest.cs b/OpenSim/Data/Tests/BasicUserTest.cs
index 4e4ddc8..f9feb9b 100644
--- a/OpenSim/Data/Tests/BasicUserTest.cs
+++ b/OpenSim/Data/Tests/BasicUserTest.cs
@@ -71,14 +71,7 @@ namespace OpenSim.Data.Tests
71 71
72 public void SuperInit() 72 public void SuperInit()
73 { 73 {
74 try 74 OpenSim.Tests.Common.TestLogging.LogToConsole();
75 {
76 XmlConfigurator.Configure();
77 }
78 catch (Exception)
79 {
80 // I don't care, just leave log4net off
81 }
82 random = new Random(); 75 random = new Random();
83 user1 = UUID.Random(); 76 user1 = UUID.Random();
84 user2 = UUID.Random(); 77 user2 = UUID.Random();
@@ -118,13 +111,6 @@ namespace OpenSim.Data.Tests
118 } 111 }
119 112
120 [Test] 113 [Test]
121 public void T999_StillNull()
122 {
123 Assert.That(db.GetUserByUUID(zero), Is.Null);
124 Assert.That(db.GetAgentByUUID(zero), Is.Null);
125 }
126
127 [Test]
128 public void T010_CreateUser() 114 public void T010_CreateUser()
129 { 115 {
130 UserProfileData u1 = NewUser(user1,fname1,lname1); 116 UserProfileData u1 = NewUser(user1,fname1,lname1);
@@ -396,6 +382,22 @@ namespace OpenSim.Data.Tests
396 Assert.That(customtype,Is.EqualTo(u1a.CustomType), "Assert.That(customtype,Is.EqualTo(u1a.CustomType))"); 382 Assert.That(customtype,Is.EqualTo(u1a.CustomType), "Assert.That(customtype,Is.EqualTo(u1a.CustomType))");
397 Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))"); 383 Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))");
398 } 384 }
385
386 [Test]
387 public void T017_UserUpdateRandomPersistency()
388 {
389 UUID id = user5;
390 UserProfileData u = db.GetUserByUUID(id);
391 new PropertyScrambler<UserProfileData>().DontScramble(x=>x.ID).Scramble(u);
392
393 db.UpdateUserProfile(u);
394 UserProfileData u1a = db.GetUserByUUID(id);
395 Assert.That(u1a, Constraints.PropertyCompareConstraint(u)
396 .IgnoreProperty(x=>x.HomeRegionX)
397 .IgnoreProperty(x=>x.HomeRegionY)
398 .IgnoreProperty(x=>x.RootInventoryFolderID)
399 );
400 }
399 401
400 [Test] 402 [Test]
401 public void T020_CreateAgent() 403 public void T020_CreateAgent()
@@ -660,6 +662,13 @@ namespace OpenSim.Data.Tests
660 Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight), "Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight))"); 662 Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight), "Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight))");
661 } 663 }
662 664
665 [Test]
666 public void T999_StillNull()
667 {
668 Assert.That(db.GetUserByUUID(zero), Is.Null);
669 Assert.That(db.GetAgentByUUID(zero), Is.Null);
670 }
671
663 public UserProfileData NewUser(UUID id,string fname,string lname) 672 public UserProfileData NewUser(UUID id,string fname,string lname)
664 { 673 {
665 UserProfileData u = new UserProfileData(); 674 UserProfileData u = new UserProfileData();
diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
index 063267b..06ca53e 100644
--- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs
+++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
@@ -69,6 +69,28 @@ 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
85 //prevent loops...
86 if (propertyNames.Count > 50)
87 {
88 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
89 failingActual = actual;
90 failingExpected = expected;
91 return false;
92 }
93
72 if (actual.GetType() != expected.GetType()) 94 if (actual.GetType() != expected.GetType())
73 { 95 {
74 propertyNames.Push("GetType()"); 96 propertyNames.Push("GetType()");
@@ -122,65 +144,69 @@ namespace OpenSim.Data.Tests
122 return true; 144 return true;
123 } 145 }
124 146
125 //Skip static properties. I had a nasty problem comparing colors because of all of the public static colors. 147 IComparable comp = actual as IComparable;
126 PropertyInfo[] properties = expected.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); 148 if (comp != null)
127 foreach (var property in properties)
128 { 149 {
129 if (ignores.Contains(property.Name)) 150 if (comp.CompareTo(expected) != 0)
130 continue; 151 {
131 152 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
132 object actualValue = property.GetValue(actual, null); 153 failingActual = actual;
133 object expectedValue = property.GetValue(expected, null); 154 failingExpected = expected;
155 return false;
156 }
157 return true;
158 }
134 159
135 //If they are both null, they are equal 160 //Now try the much more annoying IComparable<T>
136 if (actualValue == null && expectedValue == null) 161 Type icomparableInterface = actual.GetType().GetInterface("IComparable`1");
137 continue; 162 if (icomparableInterface != null)
163 {
164 int result = (int)icomparableInterface.GetMethod("CompareTo").Invoke(actual, new[] { expected });
165 if (result != 0)
166 {
167 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
168 failingActual = actual;
169 failingExpected = expected;
170 return false;
171 }
172 return true;
173 }
138 174
139 //If only one is null, then they aren't 175 IEnumerable arr = actual as IEnumerable;
140 if (actualValue == null || expectedValue == null) 176 if (arr != null)
177 {
178 List<object> actualList = arr.Cast<object>().ToList();
179 List<object> expectedList = ((IEnumerable)expected).Cast<object>().ToList();
180 if (actualList.Count != expectedList.Count)
141 { 181 {
142 propertyNames.Push(property.Name); 182 propertyNames.Push("Count");
143 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray()); 183 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
184 failingActual = actualList.Count;
185 failingExpected = expectedList.Count;
144 propertyNames.Pop(); 186 propertyNames.Pop();
145 failingActual = actualValue;
146 failingExpected = expectedValue;
147 return false; 187 return false;
148 } 188 }
149 189 //actualList and expectedList should be the same size.
150 IComparable comp = actualValue as IComparable; 190 for (int i = 0; i < actualList.Count; i++)
151 if (comp != null)
152 { 191 {
153 if (comp.CompareTo(expectedValue) != 0) 192 propertyNames.Push("[" + i + "]");
154 { 193 if (!ObjectCompare(expectedList[i], actualList[i], propertyNames))
155 propertyNames.Push(property.Name);
156 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
157 propertyNames.Pop();
158 failingActual = actualValue;
159 failingExpected = expectedValue;
160 return false; 194 return false;
161 } 195 propertyNames.Pop();
162 continue;
163 } 196 }
197 //Everything seems okay...
198 return true;
199 }
164 200
165 IEnumerable arr = actualValue as IEnumerable; 201 //Skip static properties. I had a nasty problem comparing colors because of all of the public static colors.
166 if (arr != null) 202 PropertyInfo[] properties = expected.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
167 { 203 foreach (var property in properties)
168 List<object> actualList = arr.Cast<object>().ToList(); 204 {
169 List<object> expectedList = ((IEnumerable)expectedValue).Cast<object>().ToList(); 205 if (ignores.Contains(property.Name))
170 if (actualList.Count != expectedList.Count)
171 {
172 propertyNames.Push(property.Name);
173 propertyNames.Push("Count");
174 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
175 failingActual = actualList.Count;
176 failingExpected = expectedList.Count;
177 propertyNames.Pop();
178 propertyNames.Pop();
179 }
180 //Todo: A value-wise comparison of all of the values.
181 //Everything seems okay...
182 continue; 206 continue;
183 } 207
208 object actualValue = property.GetValue(actual, null);
209 object expectedValue = property.GetValue(expected, null);
184 210
185 propertyNames.Push(property.Name); 211 propertyNames.Push(property.Name);
186 if (!ObjectCompare(expectedValue, actualValue, propertyNames)) 212 if (!ObjectCompare(expectedValue, actualValue, propertyNames))
@@ -223,15 +249,7 @@ namespace OpenSim.Data.Tests
223 { 249 {
224 //If the inside of the lambda is the access to x, we've hit the end of the chain. 250 //If the inside of the lambda is the access to x, we've hit the end of the chain.
225 // We should track by the fully scoped parameter name, but this is the first rev of doing this. 251 // We should track by the fully scoped parameter name, but this is the first rev of doing this.
226 if (((MemberExpression)express).Expression is ParameterExpression) 252 ignores.Add(((MemberExpression)express).Member.Name);
227 {
228 ignores.Add(((MemberExpression)express).Member.Name);
229 }
230 else
231 {
232 //Otherwise there could be more parameters inside...
233 PullApartExpression(((MemberExpression)express).Expression);
234 }
235 } 253 }
236 } 254 }
237 } 255 }
@@ -270,7 +288,7 @@ namespace OpenSim.Data.Tests
270 { 288 {
271 HasInt actual = new HasInt { TheValue = 5 }; 289 HasInt actual = new HasInt { TheValue = 5 };
272 HasInt expected = new HasInt { TheValue = 4 }; 290 HasInt expected = new HasInt { TheValue = 4 };
273 var constraint = Constraints.PropertyCompareConstraint(expected).IgnoreProperty(x=>x.TheValue); 291 var constraint = Constraints.PropertyCompareConstraint(expected).IgnoreProperty(x => x.TheValue);
274 292
275 Assert.That(constraint.Matches(actual), Is.True); 293 Assert.That(constraint.Matches(actual), Is.True);
276 } 294 }
@@ -312,6 +330,28 @@ namespace OpenSim.Data.Tests
312 } 330 }
313 331
314 [Test] 332 [Test]
333 public void UUIDShouldMatch()
334 {
335 UUID uuid1 = UUID.Random();
336 UUID uuid2 = UUID.Parse(uuid1.ToString());
337
338 var constraint = Constraints.PropertyCompareConstraint(uuid1);
339
340 Assert.That(constraint.Matches(uuid2), Is.True);
341 }
342
343 [Test]
344 public void UUIDShouldNotMatch()
345 {
346 UUID uuid1 = UUID.Random();
347 UUID uuid2 = UUID.Random();
348
349 var constraint = Constraints.PropertyCompareConstraint(uuid1);
350
351 Assert.That(constraint.Matches(uuid2), Is.False);
352 }
353
354 [Test]
315 public void TestColors() 355 public void TestColors()
316 { 356 {
317 Color actual = Color.Red; 357 Color actual = Color.Red;
@@ -321,5 +361,53 @@ namespace OpenSim.Data.Tests
321 361
322 Assert.That(constraint.Matches(actual), Is.True); 362 Assert.That(constraint.Matches(actual), Is.True);
323 } 363 }
364
365 [Test]
366 public void ShouldCompareLists()
367 {
368 List<int> expected = new List<int> { 1, 2, 3 };
369 List<int> actual = new List<int> { 1, 2, 3 };
370
371 var constraint = Constraints.PropertyCompareConstraint(expected);
372 Assert.That(constraint.Matches(actual), Is.True);
373 }
374
375
376 [Test]
377 public void ShouldFailToCompareListsThatAreDifferent()
378 {
379 List<int> expected = new List<int> { 1, 2, 3 };
380 List<int> actual = new List<int> { 1, 2, 4 };
381
382 var constraint = Constraints.PropertyCompareConstraint(expected);
383 Assert.That(constraint.Matches(actual), Is.False);
384 }
385
386 [Test]
387 public void ShouldFailToCompareListsThatAreDifferentLengths()
388 {
389 List<int> expected = new List<int> { 1, 2, 3 };
390 List<int> actual = new List<int> { 1, 2 };
391
392 var constraint = Constraints.PropertyCompareConstraint(expected);
393 Assert.That(constraint.Matches(actual), Is.False);
394 }
395
396 public class Recursive
397 {
398 public Recursive Other { get; set; }
399 }
400
401 [Test]
402 public void ErrorsOutOnRecursive()
403 {
404 Recursive parent = new Recursive();
405 Recursive child = new Recursive();
406 parent.Other = child;
407 child.Other = parent;
408
409 var constraint = Constraints.PropertyCompareConstraint(child);
410 Assert.That(constraint.Matches(child), Is.False);
411 }
324 } 412 }
325} \ No newline at end of file 413} \ No newline at end of file
diff --git a/OpenSim/Data/Tests/ScrambleForTesting.cs b/OpenSim/Data/Tests/PropertyScrambler.cs
index 3a22347..72aaff1 100644
--- a/OpenSim/Data/Tests/ScrambleForTesting.cs
+++ b/OpenSim/Data/Tests/PropertyScrambler.cs
@@ -27,18 +27,58 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
31using System.Linq.Expressions;
30using System.Reflection; 32using System.Reflection;
31using System.Text; 33using System.Text;
32using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse; 36using OpenMetaverse;
34using OpenSim.Framework; 37using OpenSim.Framework;
35 38
36namespace OpenSim.Data.Tests 39namespace OpenSim.Data.Tests
37{ 40{
38 public static class ScrambleForTesting 41
42 //This is generic so that the lambda expressions will work right in IDEs.
43 public class PropertyScrambler<T>
39 { 44 {
40 private static readonly Random random = new Random(); 45 readonly System.Collections.Generic.List<string> membersToNotScramble = new List<string>();
41 public static void Scramble(object obj) 46
47 private void AddExpressionToNotScrableList(Expression expression)
48 {
49 UnaryExpression unaryExpression = expression as UnaryExpression;
50 if (unaryExpression != null)
51 {
52 AddExpressionToNotScrableList(unaryExpression.Operand);
53 return;
54 }
55
56 MemberExpression memberExpression = expression as MemberExpression;
57 if (memberExpression != null)
58 {
59 if (!(memberExpression.Member is PropertyInfo))
60 {
61 throw new NotImplementedException("I don't know how deal with a MemberExpression that is a " + expression.Type);
62 }
63 membersToNotScramble.Add(memberExpression.Member.Name);
64 return;
65 }
66
67 throw new NotImplementedException("I don't know how to parse a " + expression.Type);
68 }
69
70 public PropertyScrambler<T> DontScramble(Expression<Func<T, object>> expression)
71 {
72 AddExpressionToNotScrableList(expression.Body);
73 return this;
74 }
75
76 public void Scramble(T obj)
77 {
78 internalScramble(obj);
79 }
80
81 private void internalScramble(object obj)
42 { 82 {
43 PropertyInfo[] properties = obj.GetType().GetProperties(); 83 PropertyInfo[] properties = obj.GetType().GetProperties();
44 foreach (var property in properties) 84 foreach (var property in properties)
@@ -57,13 +97,16 @@ namespace OpenSim.Data.Tests
57 { 97 {
58 foreach (object value in enumerable) 98 foreach (object value in enumerable)
59 { 99 {
60 Scramble(value); 100 internalScramble(value);
61 } 101 }
62 } 102 }
63 } 103 }
64 104
65 private static void RandomizeProperty(object obj, PropertyInfo property, object[] index) 105 private readonly Random random = new Random();
66 { 106 private void RandomizeProperty(object obj, PropertyInfo property, object[] index)
107 {//I'd like a better way to compare, but I had lots of problems with InventoryFolderBase because the ID is inherited.
108 if (membersToNotScramble.Contains(property.Name))
109 return;
67 Type t = property.PropertyType; 110 Type t = property.PropertyType;
68 if (!property.CanWrite) 111 if (!property.CanWrite)
69 return; 112 return;
@@ -71,39 +114,39 @@ namespace OpenSim.Data.Tests
71 if (value == null) 114 if (value == null)
72 return; 115 return;
73 116
74 if (t == typeof (string)) 117 if (t == typeof(string))
75 property.SetValue(obj, RandomName(), index); 118 property.SetValue(obj, RandomName(), index);
76 else if (t == typeof (UUID)) 119 else if (t == typeof(UUID))
77 property.SetValue(obj, UUID.Random(), index); 120 property.SetValue(obj, UUID.Random(), index);
78 else if (t == typeof (sbyte)) 121 else if (t == typeof(sbyte))
79 property.SetValue(obj, (sbyte)random.Next(sbyte.MinValue, sbyte.MaxValue), index); 122 property.SetValue(obj, (sbyte)random.Next(sbyte.MinValue, sbyte.MaxValue), index);
80 else if (t == typeof (short)) 123 else if (t == typeof(short))
81 property.SetValue(obj, (short)random.Next(short.MinValue, short.MaxValue), index); 124 property.SetValue(obj, (short)random.Next(short.MinValue, short.MaxValue), index);
82 else if (t == typeof (int)) 125 else if (t == typeof(int))
83 property.SetValue(obj, random.Next(), index); 126 property.SetValue(obj, random.Next(), index);
84 else if (t == typeof (long)) 127 else if (t == typeof(long))
85 property.SetValue(obj, random.Next() * int.MaxValue, index); 128 property.SetValue(obj, random.Next() * int.MaxValue, index);
86 else if (t == typeof (byte)) 129 else if (t == typeof(byte))
87 property.SetValue(obj, (byte)random.Next(byte.MinValue, byte.MaxValue), index); 130 property.SetValue(obj, (byte)random.Next(byte.MinValue, byte.MaxValue), index);
88 else if (t == typeof (ushort)) 131 else if (t == typeof(ushort))
89 property.SetValue(obj, (ushort)random.Next(ushort.MinValue, ushort.MaxValue), index); 132 property.SetValue(obj, (ushort)random.Next(ushort.MinValue, ushort.MaxValue), index);
90 else if (t == typeof (uint)) 133 else if (t == typeof(uint))
91 property.SetValue(obj, Convert.ToUInt32(random.Next()), index); 134 property.SetValue(obj, Convert.ToUInt32(random.Next()), index);
92 else if (t == typeof (ulong)) 135 else if (t == typeof(ulong))
93 property.SetValue(obj, Convert.ToUInt64(random.Next()) * Convert.ToUInt64(UInt32.MaxValue), index); 136 property.SetValue(obj, Convert.ToUInt64(random.Next()) * Convert.ToUInt64(UInt32.MaxValue), index);
94 else if (t == typeof (bool)) 137 else if (t == typeof(bool))
95 property.SetValue(obj, true, index); 138 property.SetValue(obj, true, index);
96 else if (t == typeof (byte[])) 139 else if (t == typeof(byte[]))
97 { 140 {
98 byte[] bytes = new byte[30]; 141 byte[] bytes = new byte[30];
99 random.NextBytes(bytes); 142 random.NextBytes(bytes);
100 property.SetValue(obj, bytes, index); 143 property.SetValue(obj, bytes, index);
101 } 144 }
102 else 145 else
103 Scramble(value); 146 internalScramble(value);
104 } 147 }
105 148
106 private static string RandomName() 149 private string RandomName()
107 { 150 {
108 StringBuilder name = new StringBuilder(); 151 StringBuilder name = new StringBuilder();
109 int size = random.Next(5, 12); 152 int size = random.Next(5, 12);
@@ -117,13 +160,27 @@ namespace OpenSim.Data.Tests
117 } 160 }
118 161
119 [TestFixture] 162 [TestFixture]
120 public class ScrableForTestingTest 163 public class PropertyScramblerTests
121 { 164 {
122 [Test] 165 [Test]
123 public void TestScramble() 166 public void TestScramble()
124 { 167 {
125 AssetBase actual = new AssetBase(UUID.Random(), "asset one"); 168 AssetBase actual = new AssetBase(UUID.Random(), "asset one");
126 ScrambleForTesting.Scramble(actual); 169 new PropertyScrambler<AssetBase>().Scramble(actual);
170 }
171
172 [Test]
173 public void DontScramble()
174 {
175 UUID uuid = UUID.Random();
176 AssetBase asset = new AssetBase();
177 asset.FullID = uuid;
178 new PropertyScrambler<AssetBase>()
179 .DontScramble(x => x.Metadata)
180 .DontScramble(x => x.FullID)
181 .DontScramble(x => x.ID)
182 .Scramble(asset);
183 Assert.That(asset.FullID, Is.EqualTo(uuid));
127 } 184 }
128 } 185 }
129} \ No newline at end of file 186} \ No newline at end of file