From f23856a575bf6c72de56a1eee60eca72f1724df0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 11 Dec 2008 20:36:46 +0000 Subject: * Add get child folder test --- .../Communications/Cache/InventoryFolderImpl.cs | 17 ++++++++++++++ .../Tests/Cache/UserProfileCacheServiceTests.cs | 27 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index ad55c44..933d40a 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -107,6 +107,23 @@ namespace OpenSim.Framework.Communications.Cache } /// + /// Get a child folder + /// + /// + /// The folder if it exists, null if it doesn't + public InventoryFolderImpl GetChildFolder(UUID folderID) + { + InventoryFolderImpl folder = null; + + lock (SubFolders) + { + SubFolders.TryGetValue(folderID, out folder); + } + + return folder; + } + + /// /// Removes the given child subfolder. /// /// diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index d73d3d5..f209fd4 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -112,5 +112,32 @@ namespace OpenSim.Framework.Communications.Tests Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); Assert.That(userInfo.RootFolder.SubFolders.ContainsKey(folderId), Is.True); } + + /// + /// Test retrieving a child folder + /// + [Test] + public void TestGetChildFolder() + { + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000005"); + + CommunicationsManager commsManager = new TestCommunicationsManager(); + LocalUserServices lus = (LocalUserServices)commsManager.UserService; + lus.AddPlugin(new TestUserDataPlugin()); + ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); + + lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); + + commsManager.UserProfileCacheService.RequestInventoryForUser(userId); + + CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + + 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); + } } } -- cgit v1.1