From d2d0b9877fcc6150e3a2e21283ec80ef7eda9cae Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 21 Apr 2009 15:21:27 +0000 Subject: * Add the ability to update profiles via the cache, so that cached profiles don't become stale * Add corresponding unit test --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'OpenSim/Framework/Communications/Tests') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 34f5c97..68303b0 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -29,6 +29,7 @@ using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Data; +using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Communications.Local; using OpenSim.Tests.Common.Mock; @@ -69,6 +70,34 @@ namespace OpenSim.Framework.Communications.Tests existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name"); } + + [Test] + public void TestUpdateProfile() + { + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000292"); + string firstName = "Inspector"; + string originalLastName = "Morse"; + string newLastName = "Gadget"; + + UserProfileData newProfile = new UserProfileData(); + newProfile.ID = userId; + newProfile.FirstName = firstName; + newProfile.SurName = newLastName; + + TestCommunicationsManager commsManager = new TestCommunicationsManager(); + UserProfileCacheService userCacheService = commsManager.UserProfileCacheService; + + // Check that we can't update info before it exists + Assert.That(userCacheService.UpdateProfile(newProfile), Is.False); + + // Check that we can update a profile once it exists + LocalUserServices lus = (LocalUserServices)commsManager.UserService; + lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId); + + Assert.That(userCacheService.UpdateProfile(newProfile), Is.True); + UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile; + Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); + } [Test] public void TestFetchInventory() -- cgit v1.1