refactor: Move test setup code into setup method

bulletsim
Justin Clark-Casey (justincc) 2011-07-04 22:59:36 +01:00
parent bebc51a6e0
commit f58de55c84
1 changed files with 20 additions and 13 deletions

View File

@ -47,35 +47,42 @@ namespace OpenSim.Region.CoreModules.Asset.Tests
[TestFixture] [TestFixture]
public class FlotsamAssetCacheTests public class FlotsamAssetCacheTests
{ {
[Test] protected TestScene m_scene;
public void TestCacheAsset() protected FlotsamAssetCache m_cache;
{
TestHelper.InMethod();
log4net.Config.XmlConfigurator.Configure();
[SetUp]
public void SetUp()
{
IConfigSource config = new IniConfigSource(); IConfigSource config = new IniConfigSource();
config.AddConfig("Modules"); config.AddConfig("Modules");
config.Configs["Modules"].Set("AssetCaching", "FlotsamAssetCache"); config.Configs["Modules"].Set("AssetCaching", "FlotsamAssetCache");
config.AddConfig("AssetCache"); config.AddConfig("AssetCache");
config.Configs["AssetCache"].Set("FileCacheEnabled", "false"); config.Configs["AssetCache"].Set("FileCacheEnabled", "false");
config.Configs["AssetCache"].Set("MemoryCacheEnabled", "true"); config.Configs["AssetCache"].Set("MemoryCacheEnabled", "true");
FlotsamAssetCache cache = new FlotsamAssetCache(); m_cache = new FlotsamAssetCache();
TestScene scene = SceneSetupHelpers.SetupScene(); m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, config, cache); SceneSetupHelpers.SetupSceneModules(m_scene, config, m_cache);
}
[Test]
public void TestCacheAsset()
{
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
AssetBase asset = AssetHelpers.CreateAsset(); AssetBase asset = AssetHelpers.CreateAsset();
asset.ID = TestHelper.ParseTail(0x1).ToString(); asset.ID = TestHelper.ParseTail(0x1).ToString();
// Check we don't get anything before the asset is put in the cache // Check we don't get anything before the asset is put in the cache
AssetBase retrievedAsset = cache.Get(asset.ID.ToString()); AssetBase retrievedAsset = m_cache.Get(asset.ID.ToString());
Assert.That(retrievedAsset, Is.Null); Assert.That(retrievedAsset, Is.Null);
cache.Store(asset); m_cache.Store(asset);
// Check that asset is now in cache // Check that asset is now in cache
retrievedAsset = cache.Get(asset.ID.ToString()); retrievedAsset = m_cache.Get(asset.ID.ToString());
Assert.That(retrievedAsset, Is.Not.Null); Assert.That(retrievedAsset, Is.Not.Null);
Assert.That(retrievedAsset.ID, Is.EqualTo(asset.ID)); Assert.That(retrievedAsset.ID, Is.EqualTo(asset.ID));
} }