aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs')
-rw-r--r--OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs89
1 files changed, 89 insertions, 0 deletions
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
new file mode 100644
index 0000000..fbf00d6
--- /dev/null
+++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
@@ -0,0 +1,89 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenMetaverse;
30using OpenMetaverse.Assets;
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Services.Interfaces;
34
35namespace OpenSim.Tests.Common.Setup
36{
37 /// <summary>
38 /// Utility functions for carrying out task inventory tests.
39 /// </summary>
40 ///
41 public static class TaskInventoryHelpers
42 {
43 /// <summary>
44 /// Add a notecard item to the given part.
45 /// </summary>
46 /// <param name="scene"></param>
47 /// <param name="part"></param>
48 /// <returns>The item that was added</returns>
49 public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part)
50 {
51 AssetNotecard nc = new AssetNotecard();
52 nc.BodyText = "Hello World!";
53 nc.Encode();
54 UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000");
55 UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000");
56 AssetBase ncAsset
57 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
58 scene.AssetService.Store(ncAsset);
59 TaskInventoryItem ncItem
60 = new TaskInventoryItem
61 { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid,
62 Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard };
63 part.Inventory.AddInventoryItem(ncItem, true);
64
65 return ncItem;
66 }
67
68 /// <summary>
69 /// Add a scene object item to the given part.
70 /// </summary>
71 /// <param name="scene"></param>
72 /// <param name="sop"></param>
73 /// <param name="itemName"></param>
74 /// <param name="id"></param>
75 public static TaskInventoryItem AddSceneObject(Scene scene, SceneObjectPart sop, string itemName, UUID id)
76 {
77 SceneObjectGroup taskSceneObject = SceneSetupHelpers.CreateSceneObject(1, UUID.Zero);
78 AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject);
79 scene.AssetService.Store(taskSceneObjectAsset);
80 TaskInventoryItem taskSceneObjectItem
81 = new TaskInventoryItem
82 { Name = itemName, AssetID = taskSceneObjectAsset.FullID, ItemID = id,
83 Type = (int)AssetType.Object, InvType = (int)InventoryType.Object };
84 sop.Inventory.AddInventoryItem(taskSceneObjectItem, true);
85
86 return taskSceneObjectItem;
87 }
88 }
89} \ No newline at end of file