create TestGetInventoryItem()

bulletsim
Justin Clark-Casey (justincc) 2011-06-04 00:51:49 +01:00
parent 1543fd7fff
commit 896f039513
3 changed files with 53 additions and 14 deletions

View File

@ -181,25 +181,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// <summary>
/// Find an item given a PATH_DELIMITOR delimited path starting from this folder.
///
/// This method does not handle paths that contain multiple delimitors
/// </summary>
/// <remarks>
/// This method does not handle paths that contain multiple delimiters
///
/// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some
/// XPath like expression
///
/// FIXME: Delimitors which occur in names themselves are not currently escapable.
/// </summary>
/// </remarks>
///
/// <param name="inventoryService">
/// Inventory service to query
/// </param>
/// <param name="startFolder">
/// The folder from which the path starts
/// </param>
/// <param name="path">
/// <param name="path">
/// The path to the required item.
/// </param>
/// <param name="inventoryService">Inventory service to query</param>
/// <param name="startFolder">The folder from which the path starts</param>
/// <param name="path">The path to the required item.</param>
/// <returns>null if the item is not found</returns>
public static InventoryItemBase FindItemByPath(
IInventoryService inventoryService, InventoryFolderBase startFolder, string path)

View File

@ -52,6 +52,25 @@ namespace OpenSim.Region.Framework.Tests
[TestFixture]
public class UserInventoryTests
{
[Test]
public void TestGiveInventoryItem()
{
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene);
InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID);
scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID);
InventoryItemBase retrievedItem1
= UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Objects/item1");
Assert.That(retrievedItem1, Is.Not.Null);
}
[Test]
public void TestGiveInventoryFolder()
{

View File

@ -43,7 +43,20 @@ namespace OpenSim.Tests.Common
public static readonly string PATH_DELIMITER = "/";
/// <summary>
/// Creates a notecard in the objects folder.
/// Creates a notecard in the objects folder and specify an item id.
/// </summary>
/// <param name="scene"></param>
/// <param name="itemName"></param>
/// <param name="itemId"></param>
/// <param name="userId"></param>
/// <returns></returns>
public static InventoryItemBase CreateInventoryItem(Scene scene, string itemName, UUID userId)
{
return CreateInventoryItem(scene, itemName, UUID.Random(), userId);
}
/// <summary>
/// Creates a notecard in the objects folder and specify an item id.
/// </summary>
/// <param name="scene"></param>
/// <param name="itemName"></param>
@ -139,5 +152,18 @@ namespace OpenSim.Tests.Common
else
return null;
}
/// <summary>
/// Get the inventory item that matches the path name. If there are multiple items then only the first
/// is returned.
/// </summary>
/// <param name="inventoryService"></param>
/// <param name="userId"></param>
/// <param name="path"></param>
/// <returns>null if no item matching the path was found</returns>
public static InventoryItemBase GetInventoryItem(IInventoryService inventoryService, UUID userId, string path)
{
return InventoryArchiveUtils.FindItemByPath(inventoryService, userId, path);
}
}
}