From 084059319c125983ac43534797282ddec394cb59 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 21 May 2011 00:37:20 +0100 Subject: [PATCH] refactor: move scene object item creation code into TaskInventoryHelpers --- .../Scenes/Tests/TaskInventoryTests.cs | 10 ++------ .../Common/Setup/TaskInventoryHelpers.cs | 23 ++++++++++++++++++- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 1c8f07898c..32bb06898a 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -66,15 +66,8 @@ namespace OpenSim.Region.Framework.Tests // Create an object embedded inside the first UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); - - SceneObjectGroup taskSceneObject = SceneSetupHelpers.CreateSceneObject(1, UUID.Zero); - AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); - scene.AssetService.Store(taskSceneObjectAsset); TaskInventoryItem taskSceneObjectItem - = new TaskInventoryItem - { Name = "tso", AssetID = taskSceneObjectAsset.FullID, ItemID = taskSceneObjectItemId, - Type = (int)AssetType.Object, InvType = (int)InventoryType.Object }; - sop1.Inventory.AddInventoryItem(taskSceneObjectItem, true); + = TaskInventoryHelpers.AddSceneObjectItem(scene, sop1, "tso", taskSceneObjectItemId); scene.AddSceneObject(sog1); @@ -114,6 +107,7 @@ namespace OpenSim.Region.Framework.Tests SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID); SceneObjectPart sop1 = sog1.RootPart; TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); + InventoryFolderBase folder = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; diff --git a/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs index 48724f4af4..4467573569 100644 --- a/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Setup/TaskInventoryHelpers.cs @@ -32,7 +32,7 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; -namespace OpenSim.Tests.Common +namespace OpenSim.Tests.Common.Setup { /// /// Utility functions for carrying out task inventory tests. @@ -64,5 +64,26 @@ namespace OpenSim.Tests.Common return ncItem; } + + /// + /// Add a scene object item to the given part. + /// + /// + /// + /// + /// + public static TaskInventoryItem AddSceneObjectItem(Scene scene, SceneObjectPart sop, string itemName, UUID id) + { + SceneObjectGroup taskSceneObject = SceneSetupHelpers.CreateSceneObject(1, UUID.Zero); + AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); + scene.AssetService.Store(taskSceneObjectAsset); + TaskInventoryItem taskSceneObjectItem + = new TaskInventoryItem + { Name = itemName, AssetID = taskSceneObjectAsset.FullID, ItemID = id, + Type = (int)AssetType.Object, InvType = (int)InventoryType.Object }; + sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); + + return taskSceneObjectItem; + } } } \ No newline at end of file