Add regression TestJsonGetPathType()

user_profiles
Justin Clark-Casey (justincc) 2013-02-14 21:31:34 +00:00
parent 0ad07eb44d
commit 6fe771f27e
1 changed files with 47 additions and 0 deletions

View File

@ -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] [Test]
public void TestJsonSetValue() public void TestJsonSetValue()
{ {