aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/JsonStore
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-02-12 01:27:38 +0000
committerJustin Clark-Casey (justincc)2013-02-12 01:27:38 +0000
commit586def0bcc3bad5ff1e92ff24bbd41a0d2ab4c52 (patch)
tree46c37f64fe3fe1b64e173582f999d7187c89015f /OpenSim/Region/OptionalModules/Scripting/JsonStore
parentAdd regression TestJsonGetValueJson() (diff)
downloadopensim-SC_OLD-586def0bcc3bad5ff1e92ff24bbd41a0d2ab4c52.zip
opensim-SC_OLD-586def0bcc3bad5ff1e92ff24bbd41a0d2ab4c52.tar.gz
opensim-SC_OLD-586def0bcc3bad5ff1e92ff24bbd41a0d2ab4c52.tar.bz2
opensim-SC_OLD-586def0bcc3bad5ff1e92ff24bbd41a0d2ab4c52.tar.xz
Add regression TestJsonSetValueJson()
The part to test setting of single leaf-node string tokens is currently commented out. See http://opensimulator.org/mantis/view.php?id=6540
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/JsonStore')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs58
1 files changed, 58 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
index ddbfa45..717484c 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
@@ -362,6 +362,64 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
362 } 362 }
363 } 363 }
364 364
365 [Test]
366 public void TestJsonSetValueJson()
367 {
368 TestHelpers.InMethod();
369// TestHelpers.EnableLogging();
370
371 // Single quoted token case
372// {
373// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
374//
375// int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "'Times'");
376// Assert.That(result, Is.EqualTo(1));
377//
378// string value = (string)InvokeOp("JsonGetValue", storeId, "Fun");
379// Assert.That(value, Is.EqualTo("Times"));
380// }
381
382 // Sub-tree case
383 {
384 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
385
386 int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "{ 'Filled' : 'Times' }");
387 Assert.That(result, Is.EqualTo(1));
388
389 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Filled");
390 Assert.That(value, Is.EqualTo("Times"));
391 }
392
393 // If setting single strings in JsonSetValueJson, these must be single quoted tokens, not bare strings.
394 {
395 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
396
397 int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "Times");
398 Assert.That(result, Is.EqualTo(0));
399
400 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun");
401 Assert.That(value, Is.EqualTo(""));
402 }
403
404 // Test setting to location that does not exist. This should fail.
405 {
406 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
407
408 int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun.Circus", "'Times'");
409 Assert.That(result, Is.EqualTo(0));
410
411 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Circus");
412 Assert.That(value, Is.EqualTo(""));
413 }
414
415 // Test with fake store
416 {
417 UUID fakeStoreId = TestHelpers.ParseTail(0x500);
418 int fakeStoreValueSet = (int)InvokeOp("JsonSetValueJson", fakeStoreId, "Hello", "'World'");
419 Assert.That(fakeStoreValueSet, Is.EqualTo(0));
420 }
421 }
422
365 /// <summary> 423 /// <summary>
366 /// Test for writing json to a notecard 424 /// Test for writing json to a notecard
367 /// </summary> 425 /// </summary>