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

View File

@ -52,6 +52,25 @@ namespace OpenSim.Region.Framework.Tests
[TestFixture] [TestFixture]
public class UserInventoryTests 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] [Test]
public void TestGiveInventoryFolder() public void TestGiveInventoryFolder()
{ {

View File

@ -43,7 +43,20 @@ namespace OpenSim.Tests.Common
public static readonly string PATH_DELIMITER = "/"; public static readonly string PATH_DELIMITER = "/";
/// <summary> /// <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> /// </summary>
/// <param name="scene"></param> /// <param name="scene"></param>
/// <param name="itemName"></param> /// <param name="itemName"></param>
@ -139,5 +152,18 @@ namespace OpenSim.Tests.Common
else else
return null; 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);
}
} }
} }