aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-09-08 21:06:10 +0100
committerJustin Clark-Casey (justincc)2011-09-08 21:06:10 +0100
commit9615292133ce937677d10a3acd5f71f9216e3425 (patch)
tree25fb9cb7ee7738fd8e196eb87756dc36f754c74c
parentRemember to set and unset the fire and forget method at the top of the attach... (diff)
downloadopensim-SC-9615292133ce937677d10a3acd5f71f9216e3425.zip
opensim-SC-9615292133ce937677d10a3acd5f71f9216e3425.tar.gz
opensim-SC-9615292133ce937677d10a3acd5f71f9216e3425.tar.bz2
opensim-SC-9615292133ce937677d10a3acd5f71f9216e3425.tar.xz
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
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs62
1 files 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
50 [TestFixture] 50 [TestFixture]
51 public class NPCModuleTests 51 public class NPCModuleTests
52 { 52 {
53 private TestScene scene;
54 private AvatarFactoryModule afm;
55 private UserManagementModule umm;
56 private AttachmentsModule am;
57
53 [TestFixtureSetUp] 58 [TestFixtureSetUp]
54 public void FixtureInit() 59 public void FixtureInit()
55 { 60 {
@@ -65,21 +70,28 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
65 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; 70 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
66 } 71 }
67 72
68 [Test] 73 public void Init()
69 public void TestCreate()
70 { 74 {
71 TestHelpers.InMethod();
72// log4net.Config.XmlConfigurator.Configure();
73
74 IConfigSource config = new IniConfigSource(); 75 IConfigSource config = new IniConfigSource();
75 config.AddConfig("NPC"); 76 config.AddConfig("NPC");
76 config.Configs["NPC"].Set("Enabled", "true"); 77 config.Configs["NPC"].Set("Enabled", "true");
78 config.AddConfig("Modules");
79 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
77 80
78 AvatarFactoryModule afm = new AvatarFactoryModule(); 81 afm = new AvatarFactoryModule();
79 UserManagementModule umm = new UserManagementModule(); 82 umm = new UserManagementModule();
83 am = new AttachmentsModule();
80 84
81 TestScene scene = SceneHelpers.SetupScene(); 85 TestScene scene = SceneHelpers.SetupScene();
82 SceneHelpers.SetupSceneModules(scene, config, afm, umm, new NPCModule()); 86 SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule());
87 }
88
89 [Test]
90 public void TestCreate()
91 {
92 TestHelpers.InMethod();
93// log4net.Config.XmlConfigurator.Configure();
94
83 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 95 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
84// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); 96// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
85 97
@@ -111,35 +123,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
111 TestHelpers.InMethod(); 123 TestHelpers.InMethod();
112// log4net.Config.XmlConfigurator.Configure(); 124// log4net.Config.XmlConfigurator.Configure();
113 125
114 IConfigSource config = new IniConfigSource();
115 config.AddConfig("NPC");
116 config.Configs["NPC"].Set("Enabled", "true");
117 config.AddConfig("Modules");
118 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
119
120 AvatarFactoryModule afm = new AvatarFactoryModule();
121 UserManagementModule umm = new UserManagementModule();
122 AttachmentsModule am = new AttachmentsModule();
123
124 TestScene scene = SceneHelpers.SetupScene();
125 SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule());
126
127 UUID userId = TestHelpers.ParseTail(0x1); 126 UUID userId = TestHelpers.ParseTail(0x1);
128 UserAccountHelpers.CreateUserWithInventory(scene, userId); 127 UserAccountHelpers.CreateUserWithInventory(scene, userId);
129 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); 128 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
130// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
131
132 // 8 is the index of the first baked texture in AvatarAppearance
133// UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
134// Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
135// Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
136// originalTef.TextureID = originalFace8TextureId;
137
138 // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
139 // ScenePresence.SendInitialData() to reset our entire appearance.
140// scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId));
141//
142// afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null);
143 129
144 UUID attItemId = TestHelpers.ParseTail(0x2); 130 UUID attItemId = TestHelpers.ParseTail(0x2);
145 UUID attAssetId = TestHelpers.ParseTail(0x3); 131 UUID attAssetId = TestHelpers.ParseTail(0x3);
@@ -165,6 +151,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
165 // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item 151 // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
166 // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC. 152 // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
167// Assert.That(attSo.Name, Is.EqualTo(attName)); 153// Assert.That(attSo.Name, Is.EqualTo(attName));
154
168 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); 155 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
169 Assert.That(attSo.IsAttachment); 156 Assert.That(attSo.IsAttachment);
170 Assert.That(attSo.UsesPhysics, Is.False); 157 Assert.That(attSo.UsesPhysics, Is.False);
@@ -178,13 +165,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
178 TestHelpers.InMethod(); 165 TestHelpers.InMethod();
179// log4net.Config.XmlConfigurator.Configure(); 166// log4net.Config.XmlConfigurator.Configure();
180 167
181 IConfigSource config = new IniConfigSource();
182
183 config.AddConfig("NPC");
184 config.Configs["NPC"].Set("Enabled", "true");
185
186 TestScene scene = SceneHelpers.SetupScene();
187 SceneHelpers.SetupSceneModules(scene, config, new NPCModule());
188 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 168 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
189// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); 169// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
190 170