* Add user info move inventory folder test

0.6.1-post-fixes
Justin Clarke Casey 2008-12-12 19:24:45 +00:00
parent f8ce498755
commit 7bbab12158
2 changed files with 53 additions and 10 deletions

View File

@ -73,6 +73,23 @@ 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]
public void TestGetChildFolder()
{
CommunicationsManager commsManager = UserProfileTestUtils.SetupServices();
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011");
Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null);
userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID);
Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null);
}
/// <summary> /// <summary>
/// Test creating an inventory folder /// Test creating an inventory folder
/// </summary> /// </summary>
@ -106,20 +123,40 @@ namespace OpenSim.Framework.Communications.Tests
} }
/// <summary> /// <summary>
/// Test retrieving a child folder /// Test moving an inventory folder
/// </summary> /// </summary>
[Test] [Test]
public void TestGetChildFolder() public void TestMoveFolder()
{ {
CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); IUserDataPlugin userDataPlugin = new TestUserDataPlugin();
IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin();
CommunicationsManager commsManager
= UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin);
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020");
UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021");
UUID folderToMoveId = UUID.Parse("00000000-0000-0000-0000-000000000030");
Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); InventoryFolderImpl rootFolder = userInfo.RootFolder;
userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID);
Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); userInfo.CreateFolder("folder1", folder1Id, (ushort)AssetType.Animation, rootFolder.ID);
InventoryFolderImpl folder1 = rootFolder.GetChildFolder(folder1Id);
userInfo.CreateFolder("folder2", folder2Id, (ushort)AssetType.Animation, rootFolder.ID);
InventoryFolderImpl folder2 = rootFolder.GetChildFolder(folder2Id);
// Check folder is currently in folder1
userInfo.CreateFolder("folderToMove", folderToMoveId, (ushort)AssetType.Animation, folder1Id);
Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.True);
userInfo.MoveFolder(folderToMoveId, folder2Id);
// Check folder is now in folder2 and no trace remains in folder1
Assert.That(folder2.ContainsChildFolder(folderToMoveId), Is.True);
Assert.That(inventoryDataPlugin.getInventoryFolder(folderToMoveId).ParentID, Is.EqualTo(folder2Id));
Assert.That(folder1.ContainsChildFolder(folderToMoveId), Is.False);
} }
} }
} }

View File

@ -111,7 +111,13 @@ namespace OpenSim.Tests.Common.Mock
} }
public void updateInventoryFolder(InventoryFolderBase folder) {} public void updateInventoryFolder(InventoryFolderBase folder) {}
public void moveInventoryFolder(InventoryFolderBase folder) {}
public void moveInventoryFolder(InventoryFolderBase folder)
{
// Simple replace
m_folders[folder.ID] = folder;
}
public void deleteInventoryFolder(UUID folder) {} public void deleteInventoryFolder(UUID folder) {}
public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) { return null; } public List<InventoryItemBase> fetchActiveGestures(UUID avatarID) { return null; }
} }