diff options
author | Justin Clarke Casey | 2009-01-05 18:00:53 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-01-05 18:00:53 +0000 |
commit | 0b07c9762b4c70b6d234b70fb9e591c770dc1bf1 (patch) | |
tree | 95435e1c5c8aece7224666cae400978b74fae931 /OpenSim/Framework/Communications/Tests | |
parent | * Extend stub to test the successful login of a user on the local login service (diff) | |
download | opensim-SC_OLD-0b07c9762b4c70b6d234b70fb9e591c770dc1bf1.zip opensim-SC_OLD-0b07c9762b4c70b6d234b70fb9e591c770dc1bf1.tar.gz opensim-SC_OLD-0b07c9762b4c70b6d234b70fb9e591c770dc1bf1.tar.bz2 opensim-SC_OLD-0b07c9762b4c70b6d234b70fb9e591c770dc1bf1.tar.xz |
* Simplify test code by always setting up mock 'in memory' user and inventory data plugins for every TestCommunicationsManager
* imo the gain in simplcity of test code outweighs the very small cost of setting up some stuff that some tests will never use
Diffstat (limited to 'OpenSim/Framework/Communications/Tests')
3 files changed, 22 insertions, 51 deletions
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 807afcc..44a28a2 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
52 | UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | 52 | UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
53 | UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); | 53 | UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); |
54 | 54 | ||
55 | CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); | 55 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
56 | CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, existingUserId); | 56 | CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, existingUserId); |
57 | 57 | ||
58 | Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); | 58 | Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); |
@@ -68,7 +68,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
68 | [Test] | 68 | [Test] |
69 | public void TestRequestInventoryForUser() | 69 | public void TestRequestInventoryForUser() |
70 | { | 70 | { |
71 | CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); | 71 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
72 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 72 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
73 | 73 | ||
74 | Assert.That(userInfo.HasReceivedInventory, Is.True); | 74 | Assert.That(userInfo.HasReceivedInventory, Is.True); |
@@ -80,7 +80,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
80 | [Test] | 80 | [Test] |
81 | public void TestGetChildFolder() | 81 | public void TestGetChildFolder() |
82 | { | 82 | { |
83 | CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); | 83 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
84 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 84 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
85 | 85 | ||
86 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); | 86 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); |
@@ -96,12 +96,12 @@ namespace OpenSim.Framework.Communications.Tests | |||
96 | /// </summary> | 96 | /// </summary> |
97 | [Test] | 97 | [Test] |
98 | public void TestCreateFolder() | 98 | public void TestCreateFolder() |
99 | { | 99 | { |
100 | IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); | 100 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
101 | IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); | 101 | |
102 | IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; | ||
103 | IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; | ||
102 | 104 | ||
103 | CommunicationsManager commsManager | ||
104 | = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); | ||
105 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 105 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
106 | 106 | ||
107 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); | 107 | UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); |
@@ -129,11 +129,11 @@ namespace OpenSim.Framework.Communications.Tests | |||
129 | [Test] | 129 | [Test] |
130 | public void TestUpdateFolder() | 130 | public void TestUpdateFolder() |
131 | { | 131 | { |
132 | IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); | 132 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
133 | IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); | 133 | |
134 | IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; | ||
135 | IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; | ||
134 | 136 | ||
135 | CommunicationsManager commsManager | ||
136 | = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); | ||
137 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 137 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
138 | 138 | ||
139 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 139 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
@@ -188,11 +188,11 @@ namespace OpenSim.Framework.Communications.Tests | |||
188 | [Test] | 188 | [Test] |
189 | public void TestMoveFolder() | 189 | public void TestMoveFolder() |
190 | { | 190 | { |
191 | IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); | 191 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
192 | IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); | 192 | |
193 | IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; | ||
194 | IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; | ||
193 | 195 | ||
194 | CommunicationsManager commsManager | ||
195 | = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); | ||
196 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 196 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
197 | 197 | ||
198 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 198 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
@@ -226,11 +226,11 @@ namespace OpenSim.Framework.Communications.Tests | |||
226 | { | 226 | { |
227 | //log4net.Config.XmlConfigurator.Configure(); | 227 | //log4net.Config.XmlConfigurator.Configure(); |
228 | 228 | ||
229 | IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); | 229 | TestCommunicationsManager commsManager = new TestCommunicationsManager(); |
230 | IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); | 230 | |
231 | IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; | ||
232 | IInventoryDataPlugin inventoryDataPlugin = commsManager.InventoryDataPlugin; | ||
231 | 233 | ||
232 | CommunicationsManager commsManager | ||
233 | = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); | ||
234 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 234 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); |
235 | 235 | ||
236 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); | 236 | UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); |
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs index ea209fd..cf07ae5 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs | |||
@@ -37,33 +37,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
37 | /// Utility functions for carrying out user profile relate tests. | 37 | /// Utility functions for carrying out user profile relate tests. |
38 | /// </summary> | 38 | /// </summary> |
39 | public class UserProfileTestUtils | 39 | public class UserProfileTestUtils |
40 | { | 40 | { |
41 | /// <summary> | ||
42 | /// Set up standard services required for user tests. | ||
43 | /// </summary> | ||
44 | /// <returns>CommunicationsManager used to access these services</returns> | ||
45 | public static CommunicationsManager SetupServices() | ||
46 | { | ||
47 | return SetupServices(new TestUserDataPlugin(), new TestInventoryDataPlugin()); | ||
48 | } | ||
49 | |||
50 | /// <summary> | ||
51 | /// Set up standard services required for user tests. | ||
52 | /// </summary> | ||
53 | /// <param name="userDataPlugin"></param> | ||
54 | /// <param name="inventoryDataPlugin"></param> | ||
55 | /// <returns>CommunicationsManager used to access these services</returns> | ||
56 | public static CommunicationsManager SetupServices( | ||
57 | IUserDataPlugin userDataPlugin, IInventoryDataPlugin inventoryDataPlugin) | ||
58 | { | ||
59 | CommunicationsManager commsManager = new TestCommunicationsManager(); | ||
60 | |||
61 | ((LocalUserServices)commsManager.UserService).AddPlugin(userDataPlugin); | ||
62 | ((LocalInventoryService)commsManager.InventoryService).AddPlugin(inventoryDataPlugin); | ||
63 | |||
64 | return commsManager; | ||
65 | } | ||
66 | |||
67 | /// <summary> | 41 | /// <summary> |
68 | /// Create a test user with a standard inventory | 42 | /// Create a test user with a standard inventory |
69 | /// </summary> | 43 | /// </summary> |
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 51adba1..1e1fa73 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Framework.Communications.Tests | |||
50 | [Test] | 50 | [Test] |
51 | public void TestNormalLoginResponse() | 51 | public void TestNormalLoginResponse() |
52 | { | 52 | { |
53 | log4net.Config.XmlConfigurator.Configure(); | 53 | //log4net.Config.XmlConfigurator.Configure(); |
54 | 54 | ||
55 | string firstName = "Timmy"; | 55 | string firstName = "Timmy"; |
56 | string lastName = "Mallet"; | 56 | string lastName = "Mallet"; |
@@ -58,9 +58,6 @@ namespace OpenSim.Framework.Communications.Tests | |||
58 | CommunicationsManager commsManager | 58 | CommunicationsManager commsManager |
59 | = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); | 59 | = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); |
60 | 60 | ||
61 | ((LocalUserServices)commsManager.UserService).AddPlugin(new TestUserDataPlugin()); | ||
62 | ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); | ||
63 | |||
64 | commsManager.GridService.RegisterRegion( | 61 | commsManager.GridService.RegisterRegion( |
65 | new RegionInfo(42, 43, new IPEndPoint(IPAddress.Loopback, 9000), "localhost")); | 62 | new RegionInfo(42, 43, new IPEndPoint(IPAddress.Loopback, 9000), "localhost")); |
66 | commsManager.GridService.RegionLoginsEnabled = true; | 63 | commsManager.GridService.RegionLoginsEnabled = true; |