aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs145
1 files changed, 145 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
new file mode 100644
index 0000000..397dd93
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
@@ -0,0 +1,145 @@
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 log4net;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Region.CoreModules.Scripting.ScriptModuleComms;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.ScriptEngine.Shared;
40using OpenSim.Region.ScriptEngine.Shared.Api;
41using OpenSim.Services.Interfaces;
42using OpenSim.Tests.Common;
43using OpenSim.Tests.Common.Mock;
44
45namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
46{
47 /// <summary>
48 /// Tests for inventory functions in LSL
49 /// </summary>
50 [TestFixture]
51 public class LSL_ApiInventoryTests : OpenSimTestCase
52 {
53 private Scene m_scene;
54 private MockScriptEngine m_engine;
55 private ScriptModuleCommsModule m_smcm;
56
57 [SetUp]
58 public override void SetUp()
59 {
60 base.SetUp();
61
62 TestHelpers.EnableLogging();
63
64 IConfigSource configSource = new IniConfigSource();
65 IConfig jsonStoreConfig = configSource.AddConfig("JsonStore");
66 jsonStoreConfig.Set("Enabled", "true");
67
68 m_engine = new MockScriptEngine();
69 m_smcm = new ScriptModuleCommsModule();
70 JsonStoreModule jsm = new JsonStoreModule();
71 JsonStoreScriptModule jssm = new JsonStoreScriptModule();
72
73 m_scene = new SceneHelpers().SetupScene();
74 SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm);
75 }
76
77// [Test]
78 public void TestJsonCreateStore()
79 {
80 TestHelpers.InMethod();
81// TestHelpers.EnableLogging();
82
83 UUID storeId = (UUID)m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{}" });
84
85 Assert.That(storeId, Is.Not.EqualTo(UUID.Zero));
86 }
87
88// [Test]
89 public void TestJsonGetValue()
90 {
91 TestHelpers.InMethod();
92// TestHelpers.EnableLogging();
93
94 UUID storeId
95 = (UUID)m_smcm.InvokeOperation(
96 UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" });
97
98 string value
99 = (string)m_smcm.InvokeOperation(
100 UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" });
101
102 Assert.That(value, Is.EqualTo("World"));
103 }
104
105// [Test]
106 public void TestJsonTestPath()
107 {
108 TestHelpers.InMethod();
109// TestHelpers.EnableLogging();
110
111 UUID storeId
112 = (UUID)m_smcm.InvokeOperation(
113 UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" });
114
115 int result
116 = (int)m_smcm.InvokeOperation(
117 UUID.Zero, UUID.Zero, "JsonTestPath", new object[] { storeId, "Hello" });
118
119 Assert.That(result, Is.EqualTo(1));
120 }
121
122// [Test]
123 public void TestJsonSetValue()
124 {
125 TestHelpers.InMethod();
126// TestHelpers.EnableLogging();
127
128 UUID storeId
129 = (UUID)m_smcm.InvokeOperation(
130 UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ }" });
131
132 int result
133 = (int)m_smcm.InvokeOperation(
134 UUID.Zero, UUID.Zero, "JsonSetValue", new object[] { storeId, "Hello", "World" });
135
136 Assert.That(result, Is.EqualTo(1));
137
138 string value
139 = (string)m_smcm.InvokeOperation(
140 UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" });
141
142 Assert.That(value, Is.EqualTo("World"));
143 }
144 }
145} \ No newline at end of file