* Extend get user profile test to cover retrieval by name

0.6.5-rc1
Justin Clarke Casey 2009-04-17 14:41:56 +00:00
parent 977f1e0373
commit 3db52d95ef
2 changed files with 27 additions and 36 deletions

View File

@ -30,39 +30,46 @@ using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Data; using OpenSim.Data;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Communications.Local;
using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Mock;
//using OpenSim.Framework;
namespace OpenSim.Framework.Communications.Tests namespace OpenSim.Framework.Communications.Tests
{ {
/// <summary>
/// User profile cache service tests
/// </summary>
[TestFixture] [TestFixture]
public class UserProfileCacheServiceTests public class UserProfileCacheServiceTests
{ {
/// <summary>
/// Test user details get.
/// </summary>
[Test] [Test]
public void TestGetUserDetails() public void TestGetUserDetails()
{ {
UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000002");
UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); string firstName = "Bill";
string lastName = "Bailey";
CachedUserInfo nonExistingUserInfo;
TestCommunicationsManager commsManager = new TestCommunicationsManager(); TestCommunicationsManager commsManager = new TestCommunicationsManager();
CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, existingUserId);
Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); // Check we can't retrieve info before it exists by uuid
nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
Assert.That(nonExistingUserInfo, Is.Null, "User info found by uuid before user creation");
CachedUserInfo nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(nonExistingUserId); // Check we can't retrieve info before it exists by name
nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
Assert.That(nonExistingUserInfo, Is.Null, "User info found by name before user creation");
Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found"); LocalUserServices lus = (LocalUserServices)commsManager.UserService;
lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId);
CachedUserInfo existingUserInfo;
// Check we can retrieve info by uuid
existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
Assert.That(existingUserInfo, Is.Not.Null, "User info not found by uuid");
// Check we can retrieve info by name
existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
Assert.That(existingUserInfo, Is.Not.Null, "User info not found by name");
} }
/// <summary>
/// Test requesting inventory for a user
/// </summary>
[Test] [Test]
public void TestFetchInventory() public void TestFetchInventory()
{ {
@ -72,9 +79,6 @@ namespace OpenSim.Framework.Communications.Tests
Assert.That(userInfo.HasReceivedInventory, Is.True); Assert.That(userInfo.HasReceivedInventory, Is.True);
} }
/// <summary>
/// Test retrieving a child folder
/// </summary>
[Test] [Test]
public void TestGetChildFolder() public void TestGetChildFolder()
{ {
@ -89,9 +93,6 @@ namespace OpenSim.Framework.Communications.Tests
Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null);
} }
/// <summary>
/// Test creating an inventory folder
/// </summary>
[Test] [Test]
public void TestCreateFolder() public void TestCreateFolder()
{ {
@ -119,9 +120,6 @@ namespace OpenSim.Framework.Communications.Tests
Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True);
} }
/// <summary>
/// Test updating a folder
/// </summary>
[Test] [Test]
public void TestUpdateFolder() public void TestUpdateFolder()
{ {
@ -176,9 +174,6 @@ namespace OpenSim.Framework.Communications.Tests
} }
/// <summary>
/// Test moving an inventory folder
/// </summary>
[Test] [Test]
public void TestMoveFolder() public void TestMoveFolder()
{ {
@ -210,9 +205,6 @@ namespace OpenSim.Framework.Communications.Tests
Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False); Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False);
} }
/// <summary>
/// Test purging an inventory folder
/// </summary>
[Test] [Test]
public void TestPurgeFolder() public void TestPurgeFolder()
{ {

View File

@ -32,7 +32,7 @@ using OpenSim.Region.Communications.Local;
namespace OpenSim.Framework.Communications.Tests namespace OpenSim.Framework.Communications.Tests
{ {
/// <summary> /// <summary>
/// Utility functions for carrying out user profile relate tests. /// Utility functions for carrying out user profile related tests.
/// </summary> /// </summary>
public class UserProfileTestUtils public class UserProfileTestUtils
{ {
@ -56,7 +56,6 @@ namespace OpenSim.Framework.Communications.Tests
public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager, UUID userId) public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager, UUID userId)
{ {
LocalUserServices lus = (LocalUserServices)commsManager.UserService; LocalUserServices lus = (LocalUserServices)commsManager.UserService;
lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId);
CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);