mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 20:05:33 +08:00
* Add the ability to update profiles via the cache, so that cached profiles don't become stale
* Add corresponding unit test
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user