* refactor: pull out common user profile test code into utility functions

0.6.1-post-fixes
Justin Clarke Casey 2008-12-12 18:48:29 +00:00
parent 7a4f11b94d
commit a7e145bdfd
4 changed files with 26 additions and 50 deletions

View File

@ -141,7 +141,6 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
/// <summary> /// <summary>
/// Recursively, in depth-first order, add all the folders we've received (stored /// Recursively, in depth-first order, add all the folders we've received (stored
/// in a dictionary indexed by parent ID) into the tree that describes user folder /// in a dictionary indexed by parent ID) into the tree that describes user folder

View File

@ -48,20 +48,17 @@ namespace OpenSim.Framework.Communications.Tests
[Test] [Test]
public void TestGetUserDetails() public void TestGetUserDetails()
{ {
UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001");
UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002");
CommunicationsManager commsManager = new TestCommunicationsManager(); CommunicationsManager commsManager = UserProfileTestUtils.SetupServices();
LocalUserServices lus = (LocalUserServices)commsManager.UserService; CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, existingUserId);
lus.AddPlugin(new TestUserDataPlugin());
((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin());
CachedUserInfo nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(nonExistingUserId);
Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found");
lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, existingUserId); Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found");
CachedUserInfo existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(existingUserId);
Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); CachedUserInfo nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(nonExistingUserId);
Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found");
} }
/// <summary> /// <summary>
@ -70,18 +67,9 @@ namespace OpenSim.Framework.Communications.Tests
[Test] [Test]
public void TestRequestInventoryForUser() public void TestRequestInventoryForUser()
{ {
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000003"); CommunicationsManager commsManager = UserProfileTestUtils.SetupServices();
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
CommunicationsManager commsManager = new TestCommunicationsManager();
LocalUserServices lus = (LocalUserServices)commsManager.UserService;
lus.AddPlugin(new TestUserDataPlugin());
((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin());
lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId);
commsManager.UserProfileCacheService.RequestInventoryForUser(userId);
CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
Assert.That(userInfo.HasReceivedInventory, Is.True); Assert.That(userInfo.HasReceivedInventory, Is.True);
} }
@ -91,19 +79,12 @@ namespace OpenSim.Framework.Communications.Tests
[Test] [Test]
public void TestCreateFolder() public void TestCreateFolder()
{ {
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000004"); IUserDataPlugin userDataPlugin = new TestUserDataPlugin();
IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin();
CommunicationsManager commsManager = new TestCommunicationsManager(); CommunicationsManager commsManager
LocalUserServices lus = (LocalUserServices)commsManager.UserService; = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin);
lus.AddPlugin(new TestUserDataPlugin()); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
TestInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin();
((LocalInventoryService)commsManager.InventoryService).AddPlugin(inventoryDataPlugin);
lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId);
commsManager.UserProfileCacheService.RequestInventoryForUser(userId);
CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010");
Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False);
@ -119,18 +100,8 @@ namespace OpenSim.Framework.Communications.Tests
[Test] [Test]
public void TestGetChildFolder() public void TestGetChildFolder()
{ {
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000005"); CommunicationsManager commsManager = UserProfileTestUtils.SetupServices();
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
CommunicationsManager commsManager = new TestCommunicationsManager();
LocalUserServices lus = (LocalUserServices)commsManager.UserService;
lus.AddPlugin(new TestUserDataPlugin());
((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin());
lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId);
commsManager.UserProfileCacheService.RequestInventoryForUser(userId);
CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011");

View File

@ -233,18 +233,21 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public delegate void RegisterCapsEvent(UUID agentID, Caps caps); public delegate void RegisterCapsEvent(UUID agentID, Caps caps);
public event RegisterCapsEvent OnRegisterCaps; public event RegisterCapsEvent OnRegisterCaps;
/// <summary> /// <summary>
/// DeregisterCapsEvent is called by Scene when the caps /// DeregisterCapsEvent is called by Scene when the caps
/// handler for an agent are removed. /// handler for an agent are removed.
/// </summary> /// </summary>
public delegate void DeregisterCapsEvent(UUID agentID, Caps caps); public delegate void DeregisterCapsEvent(UUID agentID, Caps caps);
public event DeregisterCapsEvent OnDeregisterCaps; public event DeregisterCapsEvent OnDeregisterCaps;
/// <summary> /// <summary>
/// ChatFromWorldEvent is called via Scene when a chat message /// ChatFromWorldEvent is called via Scene when a chat message
/// from world comes in. /// from world comes in.
/// </summary> /// </summary>
public delegate void ChatFromWorldEvent(Object sender, OSChatMessage chat); public delegate void ChatFromWorldEvent(Object sender, OSChatMessage chat);
public event ChatFromWorldEvent OnChatFromWorld; public event ChatFromWorldEvent OnChatFromWorld;
/// <summary> /// <summary>
/// ChatFromClientEvent is triggered via ChatModule (or /// ChatFromClientEvent is triggered via ChatModule (or
/// substitutes thereof) when a chat message /// substitutes thereof) when a chat message
@ -252,6 +255,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public delegate void ChatFromClientEvent(Object sender, OSChatMessage chat); public delegate void ChatFromClientEvent(Object sender, OSChatMessage chat);
public event ChatFromClientEvent OnChatFromClient; public event ChatFromClientEvent OnChatFromClient;
/// <summary> /// <summary>
/// ChatBroadcastEvent is called via Scene when a broadcast chat message /// ChatBroadcastEvent is called via Scene when a broadcast chat message
/// from world comes in /// from world comes in

View File

@ -76,13 +76,15 @@ namespace OpenSim.Region.Environment.Scenes
/// </value> /// </value>
public ILandChannel LandChannel; public ILandChannel LandChannel;
protected EventManager m_eventManager; /// <value>
/// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules
/// to subscribe to scene events.
/// </value>
public EventManager EventManager public EventManager EventManager
{ {
get { return m_eventManager; } get { return m_eventManager; }
} }
protected EventManager m_eventManager;
protected ScenePermissions m_permissions; protected ScenePermissions m_permissions;
public ScenePermissions Permissions public ScenePermissions Permissions