From 2537acc04db736cdc885e23bbfaade690d56fa5f Mon Sep 17 00:00:00 2001 From: AlexRa Date: Fri, 21 May 2010 15:59:26 +0300 Subject: Unitests: Asset, Estate, Region (the "legacy" one), Inventory The tests have been modified to work under NUnit 2.4.6 (the one currently used in the project). They will also work with NUnit 2.5+ as is, but will look better if you #define NUNIT25 for them. --- OpenSim/Data/Tests/AssetTests.cs | 62 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/Tests/AssetTests.cs') 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; using System.Data.Common; using log4net; +#if !NUNIT25 +using NUnit.Framework.SyntaxHelpers; +#endif + // DBMS-specific: using MySql.Data.MySqlClient; using OpenSim.Data.MySQL; @@ -47,25 +51,46 @@ using OpenSim.Data.SQLite; namespace OpenSim.Data.Tests { + +#if NUNIT25 + [TestFixture(typeof(MySqlConnection), typeof(MySQLAssetData), Description="Basic Asset store tests (MySQL)")] [TestFixture(typeof(SqlConnection), typeof(MSSQLAssetData), Description = "Basic Asset store tests (MS SQL Server)")] [TestFixture(typeof(SqliteConnection), typeof(SQLiteAssetData), Description = "Basic Asset store tests (SQLite)")] +#else + + [TestFixture(Description = "Region store tests (SQLite)")] + public class SQLiteAssetTests : AssetTests + { + } + + [TestFixture(Description = "Region store tests (MySQL)")] + public class MySqlAssetTests : AssetTests + { + } + + [TestFixture(Description = "Region store tests (MS SQL Server)")] + public class MSSQLAssetTests : AssetTests + { + } + +#endif + + public class AssetTests : BasicDataServiceTest where TConn : DbConnection, new() where TAssetData : AssetDataBase, new() { TAssetData m_db; - const bool COMPARE_CREATOR = false; - public UUID uuid1 = UUID.Random(); public UUID uuid2 = UUID.Random(); public UUID uuid3 = UUID.Random(); - public UUID critter1 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero; - public UUID critter2 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero; - public UUID critter3 = COMPARE_CREATOR ? UUID.Random() : UUID.Zero; + public string critter1 = UUID.Random().ToString(); + public string critter2 = UUID.Random().ToString(); + public string critter3 = UUID.Random().ToString(); public byte[] data1 = new byte[100]; @@ -157,5 +182,32 @@ namespace OpenSim.Data.Tests Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID)); } } + + [Test] + public void T020_CheckForWeirdCreatorID() + { + // It is expected that eventually the CreatorID might be an arbitrary string (an URI) + // rather than a valid UUID (?). This test is to make sure that the database layer does not + // attempt to convert CreatorID to GUID, but just passes it both ways as a string. + AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1); + AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, "This is not a GUID!"); + AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, ""); + a1.Data = data1; + a2.Data = data1; + a3.Data = data1; + + m_db.StoreAsset(a1); + m_db.StoreAsset(a2); + m_db.StoreAsset(a3); + + AssetBase a1a = m_db.GetAsset(uuid1); + Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); + + AssetBase a2a = m_db.GetAsset(uuid2); + Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); + + AssetBase a3a = m_db.GetAsset(uuid3); + Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); + } } } -- cgit v1.1