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.cs446
1 files changed, 384 insertions, 62 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
index 717484c..3d9ad16 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
@@ -53,6 +53,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
53 private Scene m_scene; 53 private Scene m_scene;
54 private MockScriptEngine m_engine; 54 private MockScriptEngine m_engine;
55 private ScriptModuleCommsModule m_smcm; 55 private ScriptModuleCommsModule m_smcm;
56 private JsonStoreScriptModule m_jssm;
56 57
57 [TestFixtureSetUp] 58 [TestFixtureSetUp]
58 public void FixtureInit() 59 public void FixtureInit()
@@ -82,10 +83,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
82 m_engine = new MockScriptEngine(); 83 m_engine = new MockScriptEngine();
83 m_smcm = new ScriptModuleCommsModule(); 84 m_smcm = new ScriptModuleCommsModule();
84 JsonStoreModule jsm = new JsonStoreModule(); 85 JsonStoreModule jsm = new JsonStoreModule();
85 JsonStoreScriptModule jssm = new JsonStoreScriptModule(); 86 m_jssm = new JsonStoreScriptModule();
86 87
87 m_scene = new SceneHelpers().SetupScene(); 88 m_scene = new SceneHelpers().SetupScene();
88 SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm); 89 SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, m_jssm);
89 90
90 try 91 try
91 { 92 {
@@ -115,8 +116,35 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
115 TestHelpers.InMethod(); 116 TestHelpers.InMethod();
116// TestHelpers.EnableLogging(); 117// TestHelpers.EnableLogging();
117 118
118 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 119 // Test blank store
119 Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); 120 {
121 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
122 Assert.That(storeId, Is.Not.EqualTo(UUID.Zero));
123 }
124
125 // Test single element store
126 {
127 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }");
128 Assert.That(storeId, Is.Not.EqualTo(UUID.Zero));
129 }
130
131 // Test with an integer value
132 {
133 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 42.15 }");
134 Assert.That(storeId, Is.Not.EqualTo(UUID.Zero));
135
136 string value = (string)InvokeOp("JsonGetValue", storeId, "Hello");
137 Assert.That(value, Is.EqualTo("42.15"));
138 }
139
140 // Test with an array as the root node
141 {
142 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "[ 'one', 'two', 'three' ]");
143 Assert.That(storeId, Is.Not.EqualTo(UUID.Zero));
144
145 string value = (string)InvokeOp("JsonGetValue", storeId, "[1]");
146 Assert.That(value, Is.EqualTo("two"));
147 }
120 } 148 }
121 149
122 [Test] 150 [Test]
@@ -181,7 +209,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
181 } 209 }
182 210
183 [Test] 211 [Test]
184 public void TestJsonGetValueJson() 212 public void TestJsonGetJson()
185 { 213 {
186 TestHelpers.InMethod(); 214 TestHelpers.InMethod();
187// TestHelpers.EnableLogging(); 215// TestHelpers.EnableLogging();
@@ -189,26 +217,26 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
189 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Two' } }"); 217 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Two' } }");
190 218
191 { 219 {
192 string value = (string)InvokeOp("JsonGetValueJson", storeId, "Hello.World"); 220 string value = (string)InvokeOp("JsonGetJson", storeId, "Hello.World");
193 Assert.That(value, Is.EqualTo("'Two'")); 221 Assert.That(value, Is.EqualTo("'Two'"));
194 } 222 }
195 223
196 // Test get of path section instead of leaf 224 // Test get of path section instead of leaf
197 { 225 {
198 string value = (string)InvokeOp("JsonGetValueJson", storeId, "Hello"); 226 string value = (string)InvokeOp("JsonGetJson", storeId, "Hello");
199 Assert.That(value, Is.EqualTo("{\"World\":\"Two\"}")); 227 Assert.That(value, Is.EqualTo("{\"World\":\"Two\"}"));
200 } 228 }
201 229
202 // Test get of non-existing value 230 // Test get of non-existing value
203 { 231 {
204 string fakeValueGet = (string)InvokeOp("JsonGetValueJson", storeId, "foo"); 232 string fakeValueGet = (string)InvokeOp("JsonGetJson", storeId, "foo");
205 Assert.That(fakeValueGet, Is.EqualTo("")); 233 Assert.That(fakeValueGet, Is.EqualTo(""));
206 } 234 }
207 235
208 // Test get from non-existing store 236 // Test get from non-existing store
209 { 237 {
210 UUID fakeStoreId = TestHelpers.ParseTail(0x500); 238 UUID fakeStoreId = TestHelpers.ParseTail(0x500);
211 string fakeStoreValueGet = (string)InvokeOp("JsonGetValueJson", fakeStoreId, "Hello"); 239 string fakeStoreValueGet = (string)InvokeOp("JsonGetJson", fakeStoreId, "Hello");
212 Assert.That(fakeStoreValueGet, Is.EqualTo("")); 240 Assert.That(fakeStoreValueGet, Is.EqualTo(""));
213 } 241 }
214 } 242 }
@@ -242,88 +270,236 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
242 TestHelpers.InMethod(); 270 TestHelpers.InMethod();
243// TestHelpers.EnableLogging(); 271// TestHelpers.EnableLogging();
244 272
245 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }"); 273 // Test remove of node in object pointing to a string
274 {
275 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }");
276
277 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello");
278 Assert.That(returnValue, Is.EqualTo(1));
279
280 int result = (int)InvokeOp("JsonTestPath", storeId, "Hello");
281 Assert.That(result, Is.EqualTo(0));
282
283 string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello");
284 Assert.That(returnValue2, Is.EqualTo(""));
285 }
286
287 // Test remove of node in object pointing to another object
288 {
289 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Wally' } }");
290
291 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello");
292 Assert.That(returnValue, Is.EqualTo(1));
293
294 int result = (int)InvokeOp("JsonTestPath", storeId, "Hello");
295 Assert.That(result, Is.EqualTo(0));
296
297 string returnValue2 = (string)InvokeOp("JsonGetJson", storeId, "Hello");
298 Assert.That(returnValue2, Is.EqualTo(""));
299 }
300
301 // Test remove of node in an array
302 {
303 UUID storeId
304 = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : [ 'value1', 'value2' ] }");
305
306 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello[0]");
307 Assert.That(returnValue, Is.EqualTo(1));
246 308
247 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello"); 309 int result = (int)InvokeOp("JsonTestPath", storeId, "Hello[0]");
248 Assert.That(returnValue, Is.EqualTo(1)); 310 Assert.That(result, Is.EqualTo(1));
311
312 result = (int)InvokeOp("JsonTestPath", storeId, "Hello[1]");
313 Assert.That(result, Is.EqualTo(0));
249 314
250 int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); 315 string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]");
251 Assert.That(result, Is.EqualTo(0)); 316 Assert.That(stringReturnValue, Is.EqualTo("value2"));
252 317
253 string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello"); 318 stringReturnValue = (string)InvokeOp("JsonGetJson", storeId, "Hello[1]");
254 Assert.That(returnValue2, Is.EqualTo("")); 319 Assert.That(stringReturnValue, Is.EqualTo(""));
320 }
255 321
256 // Test remove of non-existing value 322 // Test remove of non-existing value
257 int fakeValueRemove = (int)InvokeOp("JsonRemoveValue", storeId, "Hello"); 323 {
258 Assert.That(fakeValueRemove, Is.EqualTo(0)); 324 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }");
259 325
260 // Test get from non-existing store 326 int fakeValueRemove = (int)InvokeOp("JsonRemoveValue", storeId, "Cheese");
261 UUID fakeStoreId = TestHelpers.ParseTail(0x500); 327 Assert.That(fakeValueRemove, Is.EqualTo(0));
262 int fakeStoreValueRemove = (int)InvokeOp("JsonRemoveValue", fakeStoreId, "Hello"); 328 }
263 Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); 329
330 {
331 // Test get from non-existing store
332 UUID fakeStoreId = TestHelpers.ParseTail(0x500);
333 int fakeStoreValueRemove = (int)InvokeOp("JsonRemoveValue", fakeStoreId, "Hello");
334 Assert.That(fakeStoreValueRemove, Is.EqualTo(0));
335 }
264 } 336 }
265 337
338// [Test]
339// public void TestJsonTestPath()
340// {
341// TestHelpers.InMethod();
342//// TestHelpers.EnableLogging();
343//
344// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }");
345//
346// {
347// int result = (int)InvokeOp("JsonTestPath", storeId, "Hello.World");
348// Assert.That(result, Is.EqualTo(1));
349// }
350//
351// // Test for path which does not resolve to a value.
352// {
353// int result = (int)InvokeOp("JsonTestPath", storeId, "Hello");
354// Assert.That(result, Is.EqualTo(0));
355// }
356//
357// {
358// int result2 = (int)InvokeOp("JsonTestPath", storeId, "foo");
359// Assert.That(result2, Is.EqualTo(0));
360// }
361//
362// // Test with fake store
363// {
364// UUID fakeStoreId = TestHelpers.ParseTail(0x500);
365// int fakeStoreValueRemove = (int)InvokeOp("JsonTestPath", fakeStoreId, "Hello");
366// Assert.That(fakeStoreValueRemove, Is.EqualTo(0));
367// }
368// }
369
370// [Test]
371// public void TestJsonTestPathJson()
372// {
373// TestHelpers.InMethod();
374//// TestHelpers.EnableLogging();
375//
376// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }");
377//
378// {
379// int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello.World");
380// Assert.That(result, Is.EqualTo(1));
381// }
382//
383// // Test for path which does not resolve to a value.
384// {
385// int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello");
386// Assert.That(result, Is.EqualTo(1));
387// }
388//
389// {
390// int result2 = (int)InvokeOp("JsonTestPathJson", storeId, "foo");
391// Assert.That(result2, Is.EqualTo(0));
392// }
393//
394// // Test with fake store
395// {
396// UUID fakeStoreId = TestHelpers.ParseTail(0x500);
397// int fakeStoreValueRemove = (int)InvokeOp("JsonTestPathJson", fakeStoreId, "Hello");
398// Assert.That(fakeStoreValueRemove, Is.EqualTo(0));
399// }
400// }
401
266 [Test] 402 [Test]
267 public void TestJsonTestPath() 403 public void TestGetArrayLength()
268 { 404 {
269 TestHelpers.InMethod(); 405 TestHelpers.InMethod();
270// TestHelpers.EnableLogging(); 406// TestHelpers.EnableLogging();
271 407
272 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); 408 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }");
273 409
274 { 410 {
275 int result = (int)InvokeOp("JsonTestPath", storeId, "Hello.World"); 411 int result = (int)InvokeOp("JsonGetArrayLength", storeId, "Hello.World");
276 Assert.That(result, Is.EqualTo(1)); 412 Assert.That(result, Is.EqualTo(2));
277 } 413 }
278 414
279 // Test for path which does not resolve to a value. 415 // Test path which is not an array
280 { 416 {
281 int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); 417 int result = (int)InvokeOp("JsonGetArrayLength", storeId, "Hello");
282 Assert.That(result, Is.EqualTo(0)); 418 Assert.That(result, Is.EqualTo(-1));
283 } 419 }
284 420
421 // Test fake path
285 { 422 {
286 int result2 = (int)InvokeOp("JsonTestPath", storeId, "foo"); 423 int result = (int)InvokeOp("JsonGetArrayLength", storeId, "foo");
287 Assert.That(result2, Is.EqualTo(0)); 424 Assert.That(result, Is.EqualTo(-1));
288 } 425 }
289 426
290 // Test with fake store 427 // Test fake store
291 { 428 {
292 UUID fakeStoreId = TestHelpers.ParseTail(0x500); 429 UUID fakeStoreId = TestHelpers.ParseTail(0x500);
293 int fakeStoreValueRemove = (int)InvokeOp("JsonTestPath", fakeStoreId, "Hello"); 430 int result = (int)InvokeOp("JsonGetArrayLength", fakeStoreId, "Hello.World");
294 Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); 431 Assert.That(result, Is.EqualTo(-1));
295 } 432 }
296 } 433 }
297 434
298 [Test] 435 [Test]
299 public void TestJsonTestPathJson() 436 public void TestJsonGetPathType()
300 { 437 {
301 TestHelpers.InMethod(); 438 TestHelpers.InMethod();
302// TestHelpers.EnableLogging(); 439// TestHelpers.EnableLogging();
303 440
304 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); 441 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }");
305 442
306 { 443 {
307 int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello.World"); 444 int result = (int)InvokeOp("JsonGetPathType", storeId, ".");
308 Assert.That(result, Is.EqualTo(1)); 445 Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT));
309 } 446 }
310 447
311 // Test for path which does not resolve to a value.
312 { 448 {
313 int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello"); 449 int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello");
314 Assert.That(result, Is.EqualTo(1)); 450 Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT));
315 } 451 }
316 452
317 { 453 {
318 int result2 = (int)InvokeOp("JsonTestPathJson", storeId, "foo"); 454 int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World");
319 Assert.That(result2, Is.EqualTo(0)); 455 Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_ARRAY));
320 } 456 }
321 457
322 // Test with fake store 458 {
459 int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[0]");
460 Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE));
461 }
462
463 {
464 int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[1]");
465 Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE));
466 }
467
468 // Test for non-existant path
469 {
470 int result = (int)InvokeOp("JsonGetPathType", storeId, "foo");
471 Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
472 }
473
474 // Test for non-existant store
323 { 475 {
324 UUID fakeStoreId = TestHelpers.ParseTail(0x500); 476 UUID fakeStoreId = TestHelpers.ParseTail(0x500);
325 int fakeStoreValueRemove = (int)InvokeOp("JsonTestPathJson", fakeStoreId, "Hello"); 477 int result = (int)InvokeOp("JsonGetPathType", fakeStoreId, ".");
326 Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); 478 Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
479 }
480 }
481
482 [Test]
483 public void TestJsonList2Path()
484 {
485 TestHelpers.InMethod();
486// TestHelpers.EnableLogging();
487
488 // Invoking these methods directly since I just couldn't get comms module invocation to work for some reason
489 // - some confusion with the methods that take a params object[] invocation.
490 {
491 string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo" });
492 Assert.That(result, Is.EqualTo("{foo}"));
493 }
494
495 {
496 string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo", "bar" });
497 Assert.That(result, Is.EqualTo("{foo}.{bar}"));
498 }
499
500 {
501 string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo", 1, "bar" });
502 Assert.That(result, Is.EqualTo("{foo}.[1].{bar}"));
327 } 503 }
328 } 504 }
329 505
@@ -334,7 +510,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
334// TestHelpers.EnableLogging(); 510// TestHelpers.EnableLogging();
335 511
336 { 512 {
337 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 513 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
338 514
339 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun", "Times"); 515 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun", "Times");
340 Assert.That(result, Is.EqualTo(1)); 516 Assert.That(result, Is.EqualTo(1));
@@ -343,9 +519,155 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
343 Assert.That(value, Is.EqualTo("Times")); 519 Assert.That(value, Is.EqualTo("Times"));
344 } 520 }
345 521
522 // Test setting a key containing periods with delineation
523 {
524 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
525
526 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times");
527 Assert.That(result, Is.EqualTo(1));
528
529 string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun.Circus}");
530 Assert.That(value, Is.EqualTo("Times"));
531 }
532
533 // *** Test [] ***
534
535 // Test setting a key containing unbalanced ] without delineation. Expecting failure
536 {
537 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
538
539 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun]Circus", "Times");
540 Assert.That(result, Is.EqualTo(0));
541
542 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun]Circus");
543 Assert.That(value, Is.EqualTo(""));
544 }
545
546 // Test setting a key containing unbalanced [ without delineation. Expecting failure
547 {
548 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
549
550 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun[Circus", "Times");
551 Assert.That(result, Is.EqualTo(0));
552
553 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun[Circus");
554 Assert.That(value, Is.EqualTo(""));
555 }
556
557 // Test setting a key containing unbalanced [] without delineation. Expecting failure
558 {
559 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
560
561 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun[]Circus", "Times");
562 Assert.That(result, Is.EqualTo(0));
563
564 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun[]Circus");
565 Assert.That(value, Is.EqualTo(""));
566 }
567
568 // Test setting a key containing unbalanced ] with delineation
569 {
570 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
571
572 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun]Circus}", "Times");
573 Assert.That(result, Is.EqualTo(1));
574
575 string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun]Circus}");
576 Assert.That(value, Is.EqualTo("Times"));
577 }
578
579 // Test setting a key containing unbalanced [ with delineation
580 {
581 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
582
583 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[Circus}", "Times");
584 Assert.That(result, Is.EqualTo(1));
585
586 string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[Circus}");
587 Assert.That(value, Is.EqualTo("Times"));
588 }
589
590 // Test setting a key containing empty balanced [] with delineation
591 {
592 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
593
594 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[]Circus}", "Times");
595 Assert.That(result, Is.EqualTo(1));
596
597 string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[]Circus}");
598 Assert.That(value, Is.EqualTo("Times"));
599 }
600
601// // Commented out as this currently unexpectedly fails.
602// // Test setting a key containing brackets around an integer with delineation
603// {
604// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
605//
606// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[0]Circus}", "Times");
607// Assert.That(result, Is.EqualTo(1));
608//
609// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[0]Circus}");
610// Assert.That(value, Is.EqualTo("Times"));
611// }
612
613 // *** Test {} ***
614
615 // Test setting a key containing unbalanced } without delineation. Expecting failure (?)
616 {
617 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
618
619 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun}Circus", "Times");
620 Assert.That(result, Is.EqualTo(0));
621
622 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun}Circus");
623 Assert.That(value, Is.EqualTo(""));
624 }
625
626 // Test setting a key containing unbalanced { without delineation. Expecting failure (?)
627 {
628 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
629
630 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun{Circus", "Times");
631 Assert.That(result, Is.EqualTo(0));
632
633 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun}Circus");
634 Assert.That(value, Is.EqualTo(""));
635 }
636
637// // Commented out as this currently unexpectedly fails.
638// // Test setting a key containing unbalanced }
639// {
640// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
641//
642// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun}Circus}", "Times");
643// Assert.That(result, Is.EqualTo(0));
644// }
645
646 // Test setting a key containing unbalanced { with delineation
647 {
648 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
649
650 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun{Circus}", "Times");
651 Assert.That(result, Is.EqualTo(1));
652
653 string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun{Circus}");
654 Assert.That(value, Is.EqualTo("Times"));
655 }
656
657 // Test setting a key containing balanced {} with delineation. This should fail.
658 {
659 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
660
661 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun{Filled}Circus}", "Times");
662 Assert.That(result, Is.EqualTo(0));
663
664 string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun{Filled}Circus}");
665 Assert.That(value, Is.EqualTo(""));
666 }
667
346 // Test setting to location that does not exist. This should fail. 668 // Test setting to location that does not exist. This should fail.
347 { 669 {
348 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 670 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
349 671
350 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun.Circus", "Times"); 672 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun.Circus", "Times");
351 Assert.That(result, Is.EqualTo(0)); 673 Assert.That(result, Is.EqualTo(0));
@@ -363,27 +685,27 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
363 } 685 }
364 686
365 [Test] 687 [Test]
366 public void TestJsonSetValueJson() 688 public void TestJsonSetJson()
367 { 689 {
368 TestHelpers.InMethod(); 690 TestHelpers.InMethod();
369// TestHelpers.EnableLogging(); 691// TestHelpers.EnableLogging();
370 692
371 // Single quoted token case 693 // Single quoted token case
372// { 694 {
373// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 695 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
374// 696
375// int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "'Times'"); 697 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "'Times'");
376// Assert.That(result, Is.EqualTo(1)); 698 Assert.That(result, Is.EqualTo(1));
377// 699
378// string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); 700 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun");
379// Assert.That(value, Is.EqualTo("Times")); 701 Assert.That(value, Is.EqualTo("Times"));
380// } 702 }
381 703
382 // Sub-tree case 704 // Sub-tree case
383 { 705 {
384 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 706 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
385 707
386 int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "{ 'Filled' : 'Times' }"); 708 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "{ 'Filled' : 'Times' }");
387 Assert.That(result, Is.EqualTo(1)); 709 Assert.That(result, Is.EqualTo(1));
388 710
389 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Filled"); 711 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Filled");
@@ -394,7 +716,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
394 { 716 {
395 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 717 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
396 718
397 int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "Times"); 719 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "Times");
398 Assert.That(result, Is.EqualTo(0)); 720 Assert.That(result, Is.EqualTo(0));
399 721
400 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); 722 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun");
@@ -405,7 +727,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
405 { 727 {
406 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 728 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
407 729
408 int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun.Circus", "'Times'"); 730 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun.Circus", "'Times'");
409 Assert.That(result, Is.EqualTo(0)); 731 Assert.That(result, Is.EqualTo(0));
410 732
411 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Circus"); 733 string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Circus");
@@ -415,7 +737,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
415 // Test with fake store 737 // Test with fake store
416 { 738 {
417 UUID fakeStoreId = TestHelpers.ParseTail(0x500); 739 UUID fakeStoreId = TestHelpers.ParseTail(0x500);
418 int fakeStoreValueSet = (int)InvokeOp("JsonSetValueJson", fakeStoreId, "Hello", "'World'"); 740 int fakeStoreValueSet = (int)InvokeOp("JsonSetJson", fakeStoreId, "Hello", "'World'");
419 Assert.That(fakeStoreValueSet, Is.EqualTo(0)); 741 Assert.That(fakeStoreValueSet, Is.EqualTo(0));
420 } 742 }
421 } 743 }