From a7e145bdfdb994f4c171d32740790cffc3fc4ad3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 18:48:29 +0000 Subject: * refactor: pull out common user profile test code into utility functions --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 61 ++++++---------------- 1 file changed, 16 insertions(+), 45 deletions(-) (limited to 'OpenSim/Framework/Communications/Tests/Cache') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 9c07734..6632643 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -48,20 +48,17 @@ namespace OpenSim.Framework.Communications.Tests [Test] 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"); - CommunicationsManager commsManager = new TestCommunicationsManager(); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddPlugin(new TestUserDataPlugin()); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); - + CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, 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"); - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, existingUserId); - CachedUserInfo existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(existingUserId); - Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); + Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found"); } /// @@ -70,18 +67,9 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestRequestInventoryForUser() { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000003"); - - CommunicationsManager commsManager = new TestCommunicationsManager(); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddPlugin(new TestUserDataPlugin()); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); + CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); - 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); } @@ -91,19 +79,12 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestCreateFolder() { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000004"); - - CommunicationsManager commsManager = new TestCommunicationsManager(); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddPlugin(new TestUserDataPlugin()); - TestInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(inventoryDataPlugin); + IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); + IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); - - commsManager.UserProfileCacheService.RequestInventoryForUser(userId); - - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + CommunicationsManager commsManager + = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); @@ -119,18 +100,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestGetChildFolder() { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000005"); - - 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); + CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); -- cgit v1.1