From c992037d503470b7672392f1e396914c1e35b3ae Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 14 Feb 2013 21:31:34 +0000 Subject: [PATCH] Add regression TestJsonGetPathType() --- .../Tests/JsonStoreScriptModuleTests.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index f25f290cf8..e5555d6549 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -398,6 +398,53 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } } + [Test] + public void TestJsonGetPathType() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }"); + + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "."); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT)); + } + + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello"); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT)); + } + + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World"); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_ARRAY)); + } + + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[0]"); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE)); + } + + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[1]"); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE)); + } + + // Test for non-existant path + { + int result = (int)InvokeOp("JsonGetPathType", storeId, "foo"); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); + } + + // Test for non-existant store + { + UUID fakeStoreId = TestHelpers.ParseTail(0x500); + int result = (int)InvokeOp("JsonGetPathType", fakeStoreId, "."); + Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); + } + } + [Test] public void TestJsonSetValue() {