aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
diff options
context:
space:
mode:
authorUbitUmarov2015-09-01 11:43:07 +0100
committerUbitUmarov2015-09-01 11:43:07 +0100
commitfb78b182520fc9bb0f971afd0322029c70278ea6 (patch)
treeb4e30d383938fdeef8c92d1d1c2f44bb61d329bd /OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
parentlixo (diff)
parentMantis #7713: fixed bug introduced by 1st MOSES patch. (diff)
downloadopensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.zip
opensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.gz
opensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.bz2
opensim-SC-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.xz
Merge remote-tracking branch 'os/master'
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs143
1 files changed, 143 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
new file mode 100644
index 0000000..edc0a52
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
@@ -0,0 +1,143 @@
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 System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using OpenMetaverse;
38using OpenMetaverse.Assets;
39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
44using OpenSim.Region.CoreModules.World.Serialiser;
45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
46using OpenSim.Services.Interfaces;
47using OpenSim.Tests.Common;
48
49namespace OpenSim.Region.Framework.Tests
50{
51 [TestFixture]
52 public class UserInventoryTests : OpenSimTestCase
53 {
54 [Test]
55 public void TestCreateInventoryFolders()
56 {
57 TestHelpers.InMethod();
58// TestHelpers.EnableLogging();
59
60 // For this test both folders will have the same name which is legal in SL user inventories.
61 string foldersName = "f1";
62
63 Scene scene = new SceneHelpers().SetupScene();
64 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
65
66 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName, false);
67
68 List<InventoryFolderBase> oneFolder
69 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName);
70
71 Assert.That(oneFolder.Count, Is.EqualTo(1));
72 InventoryFolderBase firstRetrievedFolder = oneFolder[0];
73 Assert.That(firstRetrievedFolder.Name, Is.EqualTo(foldersName));
74
75 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName, false);
76
77 List<InventoryFolderBase> twoFolders
78 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName);
79
80 Assert.That(twoFolders.Count, Is.EqualTo(2));
81 Assert.That(twoFolders[0].Name, Is.EqualTo(foldersName));
82 Assert.That(twoFolders[1].Name, Is.EqualTo(foldersName));
83 Assert.That(twoFolders[0].ID, Is.Not.EqualTo(twoFolders[1].ID));
84 }
85
86 [Test]
87 public void TestGiveInventoryItem()
88 {
89 TestHelpers.InMethod();
90// log4net.Config.XmlConfigurator.Configure();
91
92 Scene scene = new SceneHelpers().SetupScene();
93 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
94 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
95 InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID);
96
97 string message;
98
99 scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID, out message);
100
101 InventoryItemBase retrievedItem1
102 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1");
103
104 Assert.That(retrievedItem1, Is.Not.Null);
105
106 // Try giving back the freshly received item
107 scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID, out message);
108
109 List<InventoryItemBase> reretrievedItems
110 = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1");
111
112 Assert.That(reretrievedItems.Count, Is.EqualTo(2));
113 }
114
115 [Test]
116 public void TestGiveInventoryFolder()
117 {
118 TestHelpers.InMethod();
119// TestHelpers.EnableLogging();
120
121 Scene scene = new SceneHelpers().SetupScene();
122 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
123 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
124 InventoryFolderBase folder1
125 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false);
126
127 scene.GiveInventoryFolder(null, user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero);
128
129 InventoryFolderBase retrievedFolder1
130 = UserInventoryHelpers.GetInventoryFolder(scene.InventoryService, user2.PrincipalID, "folder1");
131
132 Assert.That(retrievedFolder1, Is.Not.Null);
133
134 // Try giving back the freshly received folder
135 scene.GiveInventoryFolder(null, user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero);
136
137 List<InventoryFolderBase> reretrievedFolders
138 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, "folder1");
139
140 Assert.That(reretrievedFolders.Count, Is.EqualTo(2));
141 }
142 }
143} \ No newline at end of file