aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-12-12 18:59:06 +0000
committerJustin Clarke Casey2008-12-12 18:59:06 +0000
commitb60d980f7ca1a986891a8503d87c90dcd8ab0cd2 (patch)
tree72eca03bf5a04a945b696ab4ebcf8417a8f1250c /OpenSim/Framework
parent* refactor: pull out common user profile test code into utility functions (diff)
downloadopensim-SC-b60d980f7ca1a986891a8503d87c90dcd8ab0cd2.zip
opensim-SC-b60d980f7ca1a986891a8503d87c90dcd8ab0cd2.tar.gz
opensim-SC-b60d980f7ca1a986891a8503d87c90dcd8ab0cd2.tar.bz2
opensim-SC-b60d980f7ca1a986891a8503d87c90dcd8ab0cd2.tar.xz
* Add file missing from last commit
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs95
1 files changed, 95 insertions, 0 deletions
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs
new file mode 100644
index 0000000..ea209fd
--- /dev/null
+++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs
@@ -0,0 +1,95 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenMetaverse;
29using OpenSim.Framework.Communications;
30using OpenSim.Framework.Communications.Cache;
31using OpenSim.Region.Communications.Local;
32using OpenSim.Tests.Common.Mock;
33
34namespace OpenSim.Framework.Communications.Tests
35{
36 /// <summary>
37 /// Utility functions for carrying out user profile relate tests.
38 /// </summary>
39 public class UserProfileTestUtils
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>
68 /// Create a test user with a standard inventory
69 /// </summary>
70 /// <param name="commsManager"></param>
71 /// <returns></returns>
72 public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager)
73 {
74 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099");
75 return CreateUserWithInventory(commsManager, userId);
76 }
77
78 /// <summary>
79 /// Create a test user with a standard inventory
80 /// </summary>
81 /// <param name="commsManager"></param>
82 /// <param name="userId">Explicit user id to use for user creation</param>
83 /// <returns></returns>
84 public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager, UUID userId)
85 {
86 LocalUserServices lus = (LocalUserServices)commsManager.UserService;
87
88 lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId);
89
90 commsManager.UserProfileCacheService.RequestInventoryForUser(userId);
91
92 return commsManager.UserProfileCacheService.GetUserDetails(userId);
93 }
94 }
95}