Merge branch 'master' into careminster-presence-refactor

This commit is contained in:
Melanie
2010-06-12 00:08:20 +01:00
10 changed files with 219 additions and 110 deletions

View File

@@ -36,25 +36,29 @@ namespace OpenSim.Tests.Common
public class AssetHelpers
{
/// <summary>
/// Create an asset from the given data
/// Create a notecard asset with a random uuid and dummy text.
/// </summary>
public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID)
/// <param name="creatorId">/param>
/// <returns></returns>
public static AssetBase CreateAsset(UUID creatorId)
{
AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString());
asset.Data = data;
return asset;
}
/// <summary>
/// Create an asset from the given data
/// </summary>
public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string data, UUID creatorID)
{
return CreateAsset(assetUuid, assetType, Encoding.ASCII.GetBytes(data), creatorID);
return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId);
}
/// <summary>
/// Create an asset from the given scene object
/// Create and store a notecard asset with a random uuid and dummy text.
/// </summary>
/// <param name="creatorId">/param>
/// <returns></returns>
public static AssetBase CreateAsset(Scene scene, UUID creatorId)
{
AssetBase asset = CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId);
scene.AssetService.Store(asset);
return asset;
}
/// <summary>
/// Create an asset from the given scene object.
/// </summary>
/// <param name="assetUuid"></param>
/// <param name="sog"></param>
@@ -67,5 +71,23 @@ namespace OpenSim.Tests.Common
Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(sog)),
sog.OwnerID);
}
/// <summary>
/// Create an asset from the given data.
/// </summary>
public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string data, UUID creatorID)
{
return CreateAsset(assetUuid, assetType, Encoding.ASCII.GetBytes(data), creatorID);
}
/// <summary>
/// Create an asset from the given data.
/// </summary>
public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID)
{
AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString());
asset.Data = data;
return asset;
}
}
}

View File

@@ -28,6 +28,7 @@
using System;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Tests.Common
@@ -39,6 +40,23 @@ namespace OpenSim.Tests.Common
{
public static readonly string PATH_DELIMITER = "/";
public static InventoryItemBase CreateInventoryItem(
Scene scene, string itemName, UUID itemId, string folderPath, UUID userId)
{
InventoryItemBase item = new InventoryItemBase();
item.Name = itemName;
item.AssetID = AssetHelpers.CreateAsset(scene, userId).FullID;
item.ID = itemId;
// Really quite bad since the objs folder could be moved in the future and confuse the tests
InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object);
item.Folder = objsFolder.ID;
scene.AddInventoryItem(userId, item);
return item;
}
/// <summary>
/// Create inventory folders starting from the user's root folder.
/// </summary>