refactor: Use local attachment module variables instead of global m_attMod.

This also avoids confusion between tests where one sets up m_attMod and another accidentally uses it after failing to set one up itself.
0.7.4.1
Justin Clark-Casey (justincc) 2012-06-26 22:31:25 +01:00
parent 4329cc7b8a
commit 2b82c421ad
1 changed files with 10 additions and 11 deletions

View File

@ -56,8 +56,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
[TestFixture] [TestFixture]
public class AttachmentsModuleTests public class AttachmentsModuleTests
{ {
private AttachmentsModule m_attMod;
/// <summary> /// <summary>
/// Standard user ID /// Standard user ID
/// </summary> /// </summary>
@ -95,8 +93,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
Scene scene = new SceneHelpers().SetupScene(); Scene scene = new SceneHelpers().SetupScene();
m_attMod = new AttachmentsModule(); SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule());
SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule());
return scene; return scene;
} }
@ -141,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID).ParentGroup; SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID).ParentGroup;
m_attMod.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false); scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false);
// Check status on scene presence // Check status on scene presence
Assert.That(sp.HasAttachments(), Is.True); Assert.That(sp.HasAttachments(), Is.True);
@ -181,7 +178,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20);
m_attMod.RezSingleAttachmentFromInventory( scene.AttachmentsModule.RezSingleAttachmentFromInventory(
sp, attItem.ID, (uint)AttachmentPoint.Chest); sp, attItem.ID, (uint)AttachmentPoint.Chest);
// Check scene presence status // Check scene presence status
@ -213,9 +210,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20);
ISceneEntity so ISceneEntity so
= m_attMod.RezSingleAttachmentFromInventory( = scene.AttachmentsModule.RezSingleAttachmentFromInventory(
sp, attItem.ID, (uint)AttachmentPoint.Chest); sp, attItem.ID, (uint)AttachmentPoint.Chest);
m_attMod.DetachSingleAttachmentToGround(sp, so.LocalId); scene.AttachmentsModule.DetachSingleAttachmentToGround(sp, so.LocalId);
// Check scene presence status // Check scene presence status
Assert.That(sp.HasAttachments(), Is.False); Assert.That(sp.HasAttachments(), Is.False);
@ -244,9 +241,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20); InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20);
m_attMod.RezSingleAttachmentFromInventory( scene.AttachmentsModule.RezSingleAttachmentFromInventory(
sp, attItem.ID, (uint)AttachmentPoint.Chest); sp, attItem.ID, (uint)AttachmentPoint.Chest);
m_attMod.DetachSingleAttachmentToInv(sp, attItem.ID); scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, attItem.ID);
// Check status on scene presence // Check status on scene presence
Assert.That(sp.HasAttachments(), Is.False); Assert.That(sp.HasAttachments(), Is.False);
@ -364,6 +361,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
// for a callback from the destination scene before removing its avatar data. // for a callback from the destination scene before removing its avatar data.
entityTransferConfig.Set("wait_for_callback", false); entityTransferConfig.Set("wait_for_callback", false);
modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule");
SceneHelpers sh = new SceneHelpers(); SceneHelpers sh = new SceneHelpers();
TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
@ -380,7 +379,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
InventoryItemBase attItem = CreateAttachmentItem(sceneA, m_userId, "att", 0x10, 0x20); InventoryItemBase attItem = CreateAttachmentItem(sceneA, m_userId, "att", 0x10, 0x20);
m_attMod.RezSingleAttachmentFromInventory( sceneA.AttachmentsModule.RezSingleAttachmentFromInventory(
beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest); beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest);
Vector3 teleportPosition = new Vector3(10, 11, 12); Vector3 teleportPosition = new Vector3(10, 11, 12);