From 23d478f2fa06d1dedabfb24cf6ff763b586173ce Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sun, 9 Aug 2009 02:01:21 -0500 Subject: Adding in Reflection-based testing, to ensure that all properties are covered. --- OpenSim/Data/Tests/BasicAssetTest.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'OpenSim/Data/Tests/BasicAssetTest.cs') diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs index e85a6a7..eddb999 100644 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ b/OpenSim/Data/Tests/BasicAssetTest.cs @@ -32,7 +32,6 @@ using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; using log4net; -using System.Reflection; namespace OpenSim.Data.Tests { @@ -77,25 +76,31 @@ namespace OpenSim.Data.Tests AssetBase a1 = new AssetBase(uuid1, "asset one"); AssetBase a2 = new AssetBase(uuid2, "asset two"); AssetBase a3 = new AssetBase(uuid3, "asset three"); + + ScrambleForTesting.Scramble(a1); + ScrambleForTesting.Scramble(a2); + ScrambleForTesting.Scramble(a3); + a1.Data = asset1; a2.Data = asset1; a3.Data = asset1; + a1.FullID = uuid1; + a2.FullID = uuid2; + a3.FullID = uuid3; + db.CreateAsset(a1); db.CreateAsset(a2); db.CreateAsset(a3); AssetBase a1a = db.FetchAsset(uuid1); - Assert.That(a1.ID, Is.EqualTo(a1a.ID), "Assert.That(a1.ID, Is.EqualTo(a1a.ID))"); - Assert.That(a1.Name, Is.EqualTo(a1a.Name), "Assert.That(a1.Name, Is.EqualTo(a1a.Name))"); + Assert.That(a1, Constraints.PropertyCompareConstraint(a1a)); AssetBase a2a = db.FetchAsset(uuid2); - Assert.That(a2.ID, Is.EqualTo(a2a.ID), "Assert.That(a2.ID, Is.EqualTo(a2a.ID))"); - Assert.That(a2.Name, Is.EqualTo(a2a.Name), "Assert.That(a2.Name, Is.EqualTo(a2a.Name))"); + Assert.That(a2, Constraints.PropertyCompareConstraint(a2a)); AssetBase a3a = db.FetchAsset(uuid3); - Assert.That(a3.ID, Is.EqualTo(a3a.ID), "Assert.That(a3.ID, Is.EqualTo(a3a.ID))"); - Assert.That(a3.Name, Is.EqualTo(a3a.Name), "Assert.That(a3.Name, Is.EqualTo(a3a.Name))"); + Assert.That(a3, Constraints.PropertyCompareConstraint(a3a)); } [Test] -- cgit v1.1 From d2e5380cb2325ad42917c528c52a8ad42ec0176f Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sat, 15 Aug 2009 10:54:48 -0500 Subject: * 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 --- OpenSim/Data/Tests/BasicAssetTest.cs | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/Tests/BasicAssetTest.cs') 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 a1.Data = asset1; a2.Data = asset1; a3.Data = asset1; - + a1.FullID = uuid1; a2.FullID = uuid2; a3.FullID = uuid3; @@ -92,15 +92,40 @@ namespace OpenSim.Data.Tests db.CreateAsset(a1); db.CreateAsset(a2); db.CreateAsset(a3); - + AssetBase a1a = db.FetchAsset(uuid1); - Assert.That(a1, Constraints.PropertyCompareConstraint(a1a)); + Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); AssetBase a2a = db.FetchAsset(uuid2); - Assert.That(a2, Constraints.PropertyCompareConstraint(a2a)); + Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); AssetBase a3a = db.FetchAsset(uuid3); - Assert.That(a3, Constraints.PropertyCompareConstraint(a3a)); + Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); + + ScrambleForTesting.Scramble(a1a); + ScrambleForTesting.Scramble(a2a); + ScrambleForTesting.Scramble(a3a); + + a1a.Data = asset1; + a2a.Data = asset1; + a3a.Data = asset1; + + a1a.FullID = uuid1; + a2a.FullID = uuid2; + a3a.FullID = uuid3; + + db.UpdateAsset(a1a); + db.UpdateAsset(a2a); + db.UpdateAsset(a3a); + + AssetBase a1b = db.FetchAsset(uuid1); + Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a)); + + AssetBase a2b = db.FetchAsset(uuid2); + Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a)); + + AssetBase a3b = db.FetchAsset(uuid3); + Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a)); } [Test] -- cgit v1.1 From 5dde4a4cfae106805b480ae4e22e2f6c79ef3fa5 Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sat, 15 Aug 2009 23:43:52 -0500 Subject: * More improvements to BasicAssetTest.cs --- OpenSim/Data/Tests/BasicAssetTest.cs | 38 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 26 deletions(-) (limited to 'OpenSim/Data/Tests/BasicAssetTest.cs') diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs index 91b613a..23041ad 100644 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ b/OpenSim/Data/Tests/BasicAssetTest.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using log4net.Config; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; @@ -37,8 +38,7 @@ namespace OpenSim.Data.Tests { public class BasicAssetTest { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public AssetDataBase db; + public IAssetDataPlugin db; public UUID uuid1; public UUID uuid2; public UUID uuid3; @@ -46,14 +46,7 @@ namespace OpenSim.Data.Tests public void SuperInit() { - try - { - XmlConfigurator.Configure(); - } - catch (Exception) - { - // I don't care, just leave log4net off - } + OpenSim.Tests.Common.TestLogging.LogToConsole(); uuid1 = UUID.Random(); uuid2 = UUID.Random(); @@ -126,26 +119,19 @@ namespace OpenSim.Data.Tests AssetBase a3b = db.FetchAsset(uuid3); Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a)); - } - [Test] - public void T011_ExistsSimpleAsset() - { Assert.That(db.ExistsAsset(uuid1), Is.True); Assert.That(db.ExistsAsset(uuid2), Is.True); Assert.That(db.ExistsAsset(uuid3), Is.True); - } - // this has questionable use, but it is in the interface at the moment. - // [Test] - // public void T012_DeleteAsset() - // { - // db.DeleteAsset(uuid1); - // db.DeleteAsset(uuid2); - // db.DeleteAsset(uuid3); - // Assert.That(db.ExistsAsset(uuid1), Is.False); - // Assert.That(db.ExistsAsset(uuid2), Is.False); - // Assert.That(db.ExistsAsset(uuid3), Is.False); - // } + List metadatas = db.FetchAssetMetadataSet(0, 1000); + + AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1); + Assert.That(metadata.Name, Is.EqualTo(a1b.Name)); + Assert.That(metadata.Description, Is.EqualTo(a1b.Description)); + Assert.That(metadata.Type, Is.EqualTo(a1b.Type)); + Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary)); + Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID)); + } } } -- cgit v1.1 From dd78c250aed0924d06e28a826c2ad565ca232045 Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sun, 16 Aug 2009 03:35:31 -0500 Subject: * Added Expression based ignores to the PropertyScrambler, which makes a lot of the tests clearer because I'm not constantly resetting properties. --- OpenSim/Data/Tests/BasicAssetTest.cs | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'OpenSim/Data/Tests/BasicAssetTest.cs') diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs index 23041ad..09131c1 100644 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ b/OpenSim/Data/Tests/BasicAssetTest.cs @@ -69,18 +69,20 @@ namespace OpenSim.Data.Tests AssetBase a1 = new AssetBase(uuid1, "asset one"); AssetBase a2 = new AssetBase(uuid2, "asset two"); AssetBase a3 = new AssetBase(uuid3, "asset three"); - - ScrambleForTesting.Scramble(a1); - ScrambleForTesting.Scramble(a2); - ScrambleForTesting.Scramble(a3); - a1.Data = asset1; a2.Data = asset1; a3.Data = asset1; - - a1.FullID = uuid1; - a2.FullID = uuid2; - a3.FullID = uuid3; + + PropertyScrambler scrambler = new PropertyScrambler() + .DontScramble(x => x.Data) + .DontScramble(x => x.ID) + .DontScramble(x => x.FullID) + .DontScramble(x => x.Metadata.ID) + .DontScramble(x => x.Metadata.FullID); + + scrambler.Scramble(a1); + scrambler.Scramble(a2); + scrambler.Scramble(a3); db.CreateAsset(a1); db.CreateAsset(a2); @@ -95,17 +97,9 @@ namespace OpenSim.Data.Tests AssetBase a3a = db.FetchAsset(uuid3); Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); - ScrambleForTesting.Scramble(a1a); - ScrambleForTesting.Scramble(a2a); - ScrambleForTesting.Scramble(a3a); - - a1a.Data = asset1; - a2a.Data = asset1; - a3a.Data = asset1; - - a1a.FullID = uuid1; - a2a.FullID = uuid2; - a3a.FullID = uuid3; + scrambler.Scramble(a1a); + scrambler.Scramble(a2a); + scrambler.Scramble(a3a); db.UpdateAsset(a1a); db.UpdateAsset(a2a); -- cgit v1.1