From 7bbab121589a6e42e7744ffad37b35e62775b2f9 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 19:24:45 +0000 Subject: * Add user info move inventory folder test --- .../Tests/Cache/UserProfileCacheServiceTests.cs | 55 ++++++++++++++++++---- .../Tests/Common/Mock/TestInventoryDataPlugin.cs | 8 +++- 2 files changed, 53 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index a229e2a..215fa81 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -72,6 +72,23 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(userInfo.HasReceivedInventory, Is.True); } + + /// + /// Test retrieving a child folder + /// + [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); + } /// /// Test creating an inventory folder @@ -104,22 +121,42 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True); } - + /// - /// Test retrieving a child folder + /// Test moving an inventory folder /// [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); + + 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"); - UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); + InventoryFolderImpl rootFolder = userInfo.RootFolder; - Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); - userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); + 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); - Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Not.Null); - } + // 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); + } } } diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs index 9e2116a..52b469b 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs @@ -111,7 +111,13 @@ namespace OpenSim.Tests.Common.Mock } 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 List fetchActiveGestures(UUID avatarID) { return null; } } -- cgit v1.1