diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/Tests/AssetTests.cs | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs index acd5449..d228c1f 100644 --- a/OpenSim/Data/Tests/AssetTests.cs +++ b/OpenSim/Data/Tests/AssetTests.cs | |||
@@ -35,6 +35,10 @@ using OpenSim.Framework; | |||
35 | using System.Data.Common; | 35 | using System.Data.Common; |
36 | using log4net; | 36 | using log4net; |
37 | 37 | ||
38 | #if !NUNIT25 | ||
39 | using NUnit.Framework.SyntaxHelpers; | ||
40 | #endif | ||
41 | |||
38 | // DBMS-specific: | 42 | // DBMS-specific: |
39 | using MySql.Data.MySqlClient; | 43 | using MySql.Data.MySqlClient; |
40 | using OpenSim.Data.MySQL; | 44 | using OpenSim.Data.MySQL; |
@@ -47,25 +51,46 @@ using OpenSim.Data.SQLite; | |||
47 | 51 | ||
48 | namespace OpenSim.Data.Tests | 52 | namespace OpenSim.Data.Tests |
49 | { | 53 | { |
54 | |||
55 | #if NUNIT25 | ||
56 | |||
50 | [TestFixture(typeof(MySqlConnection), typeof(MySQLAssetData), Description="Basic Asset store tests (MySQL)")] | 57 | [TestFixture(typeof(MySqlConnection), typeof(MySQLAssetData), Description="Basic Asset store tests (MySQL)")] |
51 | [TestFixture(typeof(SqlConnection), typeof(MSSQLAssetData), Description = "Basic Asset store tests (MS SQL Server)")] | 58 | [TestFixture(typeof(SqlConnection), typeof(MSSQLAssetData), Description = "Basic Asset store tests (MS SQL Server)")] |
52 | [TestFixture(typeof(SqliteConnection), typeof(SQLiteAssetData), Description = "Basic Asset store tests (SQLite)")] | 59 | [TestFixture(typeof(SqliteConnection), typeof(SQLiteAssetData), Description = "Basic Asset store tests (SQLite)")] |
53 | 60 | ||
61 | #else | ||
62 | |||
63 | [TestFixture(Description = "Region store tests (SQLite)")] | ||
64 | public class SQLiteAssetTests : AssetTests<SqliteConnection, SQLiteAssetData> | ||
65 | { | ||
66 | } | ||
67 | |||
68 | [TestFixture(Description = "Region store tests (MySQL)")] | ||
69 | public class MySqlAssetTests : AssetTests<MySqlConnection, MySQLAssetData> | ||
70 | { | ||
71 | } | ||
72 | |||
73 | [TestFixture(Description = "Region store tests (MS SQL Server)")] | ||
74 | public class MSSQLAssetTests : AssetTests<SqlConnection, MSSQLAssetData> | ||
75 | { | ||
76 | } | ||
77 | |||
78 | #endif | ||
79 | |||
80 | |||
54 | public class AssetTests<TConn, TAssetData> : BasicDataServiceTest<TConn, TAssetData> | 81 | public class AssetTests<TConn, TAssetData> : BasicDataServiceTest<TConn, TAssetData> |
55 | where TConn : DbConnection, new() | 82 | where TConn : DbConnection, new() |
56 | where TAssetData : AssetDataBase, new() | 83 | where TAssetData : AssetDataBase, new() |
57 | { | 84 | { |
58 | TAssetData m_db; | 85 | TAssetData m_db; |
59 | 86 | ||
60 | const bool COMPARE_CREATOR = false; | ||
61 | |||
62 | public UUID uuid1 = UUID.Random(); | 87 | public UUID uuid1 = UUID.Random(); |
63 | public UUID uuid2 = UUID.Random(); | 88 | public UUID uuid2 = UUID.Random(); |
64 | public UUID uuid3 = UUID.Random(); | 89 | public UUID uuid3 = UUID.Random(); |
65 | 90 | ||
66 | public UUID critter1 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero; | 91 | public string critter1 = UUID.Random().ToString(); |
67 | public UUID critter2 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero; | 92 | public string critter2 = UUID.Random().ToString(); |
68 | public UUID critter3 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero; | 93 | public string critter3 = UUID.Random().ToString(); |
69 | 94 | ||
70 | public byte[] data1 = new byte[100]; | 95 | public byte[] data1 = new byte[100]; |
71 | 96 | ||
@@ -157,5 +182,32 @@ namespace OpenSim.Data.Tests | |||
157 | Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID)); | 182 | Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID)); |
158 | } | 183 | } |
159 | } | 184 | } |
185 | |||
186 | [Test] | ||
187 | public void T020_CheckForWeirdCreatorID() | ||
188 | { | ||
189 | // It is expected that eventually the CreatorID might be an arbitrary string (an URI) | ||
190 | // rather than a valid UUID (?). This test is to make sure that the database layer does not | ||
191 | // attempt to convert CreatorID to GUID, but just passes it both ways as a string. | ||
192 | AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1); | ||
193 | AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, "This is not a GUID!"); | ||
194 | AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, ""); | ||
195 | a1.Data = data1; | ||
196 | a2.Data = data1; | ||
197 | a3.Data = data1; | ||
198 | |||
199 | m_db.StoreAsset(a1); | ||
200 | m_db.StoreAsset(a2); | ||
201 | m_db.StoreAsset(a3); | ||
202 | |||
203 | AssetBase a1a = m_db.GetAsset(uuid1); | ||
204 | Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); | ||
205 | |||
206 | AssetBase a2a = m_db.GetAsset(uuid2); | ||
207 | Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); | ||
208 | |||
209 | AssetBase a3a = m_db.GetAsset(uuid3); | ||
210 | Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); | ||
211 | } | ||
160 | } | 212 | } |
161 | } | 213 | } |