diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs new file mode 100644 index 0000000..f848e80 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | |||
@@ -0,0 +1,104 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Threading; | ||
33 | using System.Timers; | ||
34 | using Timer=System.Timers.Timer; | ||
35 | using Nini.Config; | ||
36 | using NUnit.Framework; | ||
37 | using NUnit.Framework.SyntaxHelpers; | ||
38 | using OpenMetaverse; | ||
39 | using OpenMetaverse.Assets; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.Communications; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; | ||
45 | using OpenSim.Region.CoreModules.World.Serialiser; | ||
46 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
47 | using OpenSim.Tests.Common; | ||
48 | using OpenSim.Tests.Common.Mock; | ||
49 | using OpenSim.Tests.Common.Setup; | ||
50 | |||
51 | namespace OpenSim.Region.Framework.Tests | ||
52 | { | ||
53 | [TestFixture] | ||
54 | public class TaskInventoryTests | ||
55 | { | ||
56 | /// <summary> | ||
57 | /// Test MoveTaskInventoryItem where the item has no parent folder assigned. | ||
58 | /// </summary> | ||
59 | /// This should place it in the most suitable user folder. | ||
60 | [Test] | ||
61 | public void TestMoveTaskInventoryItemNoParent() | ||
62 | { | ||
63 | TestHelper.InMethod(); | ||
64 | // log4net.Config.XmlConfigurator.Configure(); | ||
65 | |||
66 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
67 | |||
68 | // Create user | ||
69 | string userFirstName = "Jock"; | ||
70 | string userLastName = "Stirrup"; | ||
71 | string userPassword = "troll"; | ||
72 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
73 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); | ||
74 | |||
75 | // Create scene object | ||
76 | string part1Name = "part1"; | ||
77 | UUID part1Id = UUID.Parse("10000000-0000-0000-0000-000000000000"); | ||
78 | SceneObjectPart part1 | ||
79 | = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) | ||
80 | { Name = part1Name, UUID = part1Id }; | ||
81 | SceneObjectGroup so = new SceneObjectGroup(part1); | ||
82 | |||
83 | // Create scene object inventory item | ||
84 | AssetNotecard nc = new AssetNotecard("Hello World!"); | ||
85 | UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); | ||
86 | UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); | ||
87 | AssetBase ncAsset | ||
88 | = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); | ||
89 | scene.AssetService.Store(ncAsset); | ||
90 | TaskInventoryItem ncItem | ||
91 | = new TaskInventoryItem | ||
92 | { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid, | ||
93 | Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; | ||
94 | part1.Inventory.AddInventoryItem(ncItem, true); | ||
95 | |||
96 | // Perform test | ||
97 | scene.MoveTaskInventoryItem(userId, UUID.Zero, part1, ncItemUuid); | ||
98 | |||
99 | InventoryItemBase ncUserItem | ||
100 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userId, "Notecards/ncItem"); | ||
101 | Assert.That(ncUserItem, Is.Not.Null, "Notecards/ncItem was not found"); | ||
102 | } | ||
103 | } | ||
104 | } \ No newline at end of file | ||