refactor: remove common presence set up in attachments tests

bulletsim
Justin Clark-Casey (justincc) 2011-08-26 22:24:51 +01:00
parent dc61bf4b1f
commit 040ad11e61
1 changed files with 38 additions and 32 deletions

View File

@ -56,6 +56,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
{ {
private Scene scene; private Scene scene;
private AttachmentsModule m_attMod; private AttachmentsModule m_attMod;
private ScenePresence m_presence;
[SetUp] [SetUp]
public void Init() public void Init()
@ -80,24 +81,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
} }
/// <summary>
/// Add the standard presence for a test.
/// </summary>
private void AddPresence()
{
UUID userId = TestHelpers.ParseTail(0x1);
UserAccountHelpers.CreateUserWithInventory(scene, userId);
m_presence = SceneHelpers.AddScenePresence(scene, userId);
}
[Test] [Test]
public void TestAddAttachmentFromGround() public void TestAddAttachmentFromGround()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure(); // log4net.Config.XmlConfigurator.Configure();
UUID userId = TestHelpers.ParseTail(0x1); AddPresence();
string attName = "att"; string attName = "att";
UserAccountHelpers.CreateUserWithInventory(scene, userId);
ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId);
SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup; SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup;
m_attMod.AttachObject(presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); m_attMod.AttachObject(m_presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false);
// Check status on scene presence // Check status on scene presence
Assert.That(presence.HasAttachments(), Is.True); Assert.That(m_presence.HasAttachments(), Is.True);
List<SceneObjectGroup> attachments = presence.Attachments; List<SceneObjectGroup> attachments = m_presence.Attachments;
Assert.That(attachments.Count, Is.EqualTo(1)); Assert.That(attachments.Count, Is.EqualTo(1));
SceneObjectGroup attSo = attachments[0]; SceneObjectGroup attSo = attachments[0];
Assert.That(attSo.Name, Is.EqualTo(attName)); Assert.That(attSo.Name, Is.EqualTo(attName));
@ -107,7 +116,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(attSo.IsTemporary, Is.False); Assert.That(attSo.IsTemporary, Is.False);
// Check item status // Check item status
Assert.That(presence.Appearance.GetAttachpoint( Assert.That(m_presence.Appearance.GetAttachpoint(
attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest)); attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest));
} }
@ -117,23 +126,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure(); // log4net.Config.XmlConfigurator.Configure();
UUID userId = TestHelpers.ParseTail(0x1); AddPresence();
UUID attItemId = TestHelpers.ParseTail(0x2); UUID attItemId = TestHelpers.ParseTail(0x2);
UUID attAssetId = TestHelpers.ParseTail(0x3); UUID attAssetId = TestHelpers.ParseTail(0x3);
string attName = "att"; string attName = "att";
UserAccountHelpers.CreateUserWithInventory(scene, userId);
ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId);
InventoryItemBase attItem InventoryItemBase attItem
= UserInventoryHelpers.CreateInventoryItem( = UserInventoryHelpers.CreateInventoryItem(
scene, attName, attItemId, attAssetId, userId, InventoryType.Object); scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
m_attMod.RezSingleAttachmentFromInventory( m_attMod.RezSingleAttachmentFromInventory(
presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
// Check status on scene presence // Check status on scene presence
Assert.That(presence.HasAttachments(), Is.True); Assert.That(m_presence.HasAttachments(), Is.True);
List<SceneObjectGroup> attachments = presence.Attachments; List<SceneObjectGroup> attachments = m_presence.Attachments;
Assert.That(attachments.Count, Is.EqualTo(1)); Assert.That(attachments.Count, Is.EqualTo(1));
SceneObjectGroup attSo = attachments[0]; SceneObjectGroup attSo = attachments[0];
Assert.That(attSo.Name, Is.EqualTo(attName)); Assert.That(attSo.Name, Is.EqualTo(attName));
@ -143,7 +151,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(attSo.IsTemporary, Is.False); Assert.That(attSo.IsTemporary, Is.False);
// Check item status // Check item status
Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest));
} }
[Test] [Test]
@ -152,24 +160,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure(); // log4net.Config.XmlConfigurator.Configure();
UUID userId = TestHelpers.ParseTail(0x1); AddPresence();
UUID attItemId = TestHelpers.ParseTail(0x2); UUID attItemId = TestHelpers.ParseTail(0x2);
UUID attAssetId = TestHelpers.ParseTail(0x3); UUID attAssetId = TestHelpers.ParseTail(0x3);
string attName = "att"; string attName = "att";
UserAccountHelpers.CreateUserWithInventory(scene, userId);
ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId);
InventoryItemBase attItem InventoryItemBase attItem
= UserInventoryHelpers.CreateInventoryItem( = UserInventoryHelpers.CreateInventoryItem(
scene, attName, attItemId, attAssetId, userId, InventoryType.Object); scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
UUID attSoId = m_attMod.RezSingleAttachmentFromInventory( UUID attSoId = m_attMod.RezSingleAttachmentFromInventory(
presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
m_attMod.DetachSingleAttachmentToGround(attSoId, presence.ControllingClient); m_attMod.DetachSingleAttachmentToGround(attSoId, m_presence.ControllingClient);
// Check status on scene presence // Check status on scene presence
Assert.That(presence.HasAttachments(), Is.False); Assert.That(m_presence.HasAttachments(), Is.False);
List<SceneObjectGroup> attachments = presence.Attachments; List<SceneObjectGroup> attachments = m_presence.Attachments;
Assert.That(attachments.Count, Is.EqualTo(0)); Assert.That(attachments.Count, Is.EqualTo(0));
// Check item status // Check item status
@ -185,28 +192,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure(); // log4net.Config.XmlConfigurator.Configure();
UUID userId = TestHelpers.ParseTail(0x1); AddPresence();
UUID attItemId = TestHelpers.ParseTail(0x2); UUID attItemId = TestHelpers.ParseTail(0x2);
UUID attAssetId = TestHelpers.ParseTail(0x3); UUID attAssetId = TestHelpers.ParseTail(0x3);
string attName = "att"; string attName = "att";
UserAccountHelpers.CreateUserWithInventory(scene, userId);
ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId);
InventoryItemBase attItem InventoryItemBase attItem
= UserInventoryHelpers.CreateInventoryItem( = UserInventoryHelpers.CreateInventoryItem(
scene, attName, attItemId, attAssetId, userId, InventoryType.Object); scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
m_attMod.RezSingleAttachmentFromInventory( m_attMod.RezSingleAttachmentFromInventory(
presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
m_attMod.DetachSingleAttachmentToInv(attItemId, presence.ControllingClient); m_attMod.DetachSingleAttachmentToInv(attItemId, m_presence.ControllingClient);
// Check status on scene presence // Check status on scene presence
Assert.That(presence.HasAttachments(), Is.False); Assert.That(m_presence.HasAttachments(), Is.False);
List<SceneObjectGroup> attachments = presence.Attachments; List<SceneObjectGroup> attachments = m_presence.Attachments;
Assert.That(attachments.Count, Is.EqualTo(0)); Assert.That(attachments.Count, Is.EqualTo(0));
// Check item status // Check item status
Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0));
} }
[Test] [Test]