From 9615292133ce937677d10a3acd5f71f9216e3425 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 8 Sep 2011 21:06:10 +0100 Subject: Centralize module setup for NPC tests. This is overkill for some tests since they dont' need all the modules, but I think the gain in code readability is worth it --- .../World/NPC/Tests/NPCModuleTests.cs | 62 ++++++++-------------- 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 018cf88..10d8bfa 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -50,6 +50,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests [TestFixture] public class NPCModuleTests { + private TestScene scene; + private AvatarFactoryModule afm; + private UserManagementModule umm; + private AttachmentsModule am; + [TestFixtureSetUp] public void FixtureInit() { @@ -65,21 +70,28 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; } - [Test] - public void TestCreate() + public void Init() { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - IConfigSource config = new IniConfigSource(); config.AddConfig("NPC"); config.Configs["NPC"].Set("Enabled", "true"); + config.AddConfig("Modules"); + config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); - AvatarFactoryModule afm = new AvatarFactoryModule(); - UserManagementModule umm = new UserManagementModule(); + afm = new AvatarFactoryModule(); + umm = new UserManagementModule(); + am = new AttachmentsModule(); TestScene scene = SceneHelpers.SetupScene(); - SceneHelpers.SetupSceneModules(scene, config, afm, umm, new NPCModule()); + SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule()); + } + + [Test] + public void TestCreate() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); @@ -111,35 +123,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - IConfigSource config = new IniConfigSource(); - config.AddConfig("NPC"); - config.Configs["NPC"].Set("Enabled", "true"); - config.AddConfig("Modules"); - config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); - - AvatarFactoryModule afm = new AvatarFactoryModule(); - UserManagementModule umm = new UserManagementModule(); - AttachmentsModule am = new AttachmentsModule(); - - TestScene scene = SceneHelpers.SetupScene(); - SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule()); - UUID userId = TestHelpers.ParseTail(0x1); UserAccountHelpers.CreateUserWithInventory(scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); -// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); - - // 8 is the index of the first baked texture in AvatarAppearance -// UUID originalFace8TextureId = TestHelpers.ParseTail(0x10); -// Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero); -// Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8); -// originalTef.TextureID = originalFace8TextureId; - - // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell - // ScenePresence.SendInitialData() to reset our entire appearance. -// scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); -// -// afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null); UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); @@ -165,6 +151,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC. // Assert.That(attSo.Name, Is.EqualTo(attName)); + Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); @@ -178,13 +165,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - IConfigSource config = new IniConfigSource(); - - config.AddConfig("NPC"); - config.Configs["NPC"].Set("Enabled", "true"); - - TestScene scene = SceneHelpers.SetupScene(); - SceneHelpers.SetupSceneModules(scene, config, new NPCModule()); ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); -- cgit v1.1